def reset(self): self.token = None self.unary_operators = "!" self.binary_operators = frozenset(["&&", "||", "=="]) self.tokenizer = Tokenizer() self.token_generator = None self.tree = Treebuilder(DataNode(None)) self.expr_builder = None self.expr_builders = []
def data_block(self): while self.token[0] == token_types.string: self.tree.append(KeyValueNode(self.token[1])) self.consume() self.expect(token_types.separator) self.value_block() self.tree.pop() while self.token == (token_types.paren, "["): self.consume() if self.token[0] != token_types.string: raise ParseError self.tree.append(DataNode(self.token[1])) self.consume() self.expect(token_types.paren, "]") if self.token[0] == token_types.group_start: self.consume() self.data_block() self.eof_or_end_group() self.tree.pop()
def data_block(self): while self.token[0] == token_types.string: self.tree.append(KeyValueNode(self.token[1])) self.consume() self.expect(token_types.separator) self.value_block() self.tree.pop() while self.token == (token_types.paren, "["): self.consume() if self.token[0] != token_types.string: raise ParseError(self.tokenizer.filename, self.tokenizer.line_number, "Token '{}' is not a string".format(self.token[0])) self.tree.append(DataNode(self.token[1])) self.consume() self.expect(token_types.paren, "]") if self.token[0] == token_types.group_start: self.consume() self.data_block() self.eof_or_end_group() self.tree.pop()