Skip to content

Commit

Permalink
Bug fix, switched factory and symbol_table arguments in sub-parser fu…
Browse files Browse the repository at this point in the history
…nctions.
  • Loading branch information
takev committed Oct 28, 2013
1 parent 63f79ca commit 2f13a16
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

2013-10-28 Take Vos <[email protected]>

* Bug fix, switched arguments on sub-parser methods.

2013-10-26 Take Vos <[email protected]>

* You can now pass a symbol table to the parser, so that your AST object can save
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

AC_PREREQ(2.61)
AC_INIT(yyast, 1.2.0, [email protected])
AC_INIT(yyast, 1.2.1, [email protected])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([buildutils])
AM_INIT_AUTOMAKE()
Expand Down
22 changes: 11 additions & 11 deletions pyext/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,41 @@ def register_factory(self, node_name, factory):
"""
self.factories[node_name] = factory

def parse_null_node(self, symbol_table, factory, node_info, internal_data):
def parse_null_node(self, factory, symbol_table, node_info, internal_data):
if len(internal_data) > 0:
raise YYASTParserException("Null node should not have data.")

node = factory(symbol_table, node_info)
node.parsing_done()
return node

def parse_leaf_node(self, symbol_table, factory, node_info, internal_data):
def parse_leaf_node(self, factory, symbol_table, node_info, internal_data):
if len(internal_data) > 0:
raise YYASTParserException("Leaf node should not have data.")

node = factory(symbol_table, node_info)
node.parsing_done()
return node

def parse_branch_node(self, symbol_table, factory, node_info, internal_data):
def parse_branch_node(self, factory, symbol_table, node_info, internal_data):
node = factory(symbol_table, node_info)

# Parse the child nodes and add it to the node.
while internal_data:
child_node, internal_data = self.parse_node(internal_data)
child_node, internal_data = self.parse_node(symbol_table, internal_data)
node.add_child(child_node)

node.parsing_done()
return node

def parse_text_node(self, symbol_table, factory, node_info, internal_data):
def parse_text_node(self, factory, symbol_table, node_info, internal_data):
internal_data = strip_null(internal_data)
value = internal_data.decode("UTF-8")
node = factory(symbol_table, node_info, value)
node.parsing_done()
return node

def parse_positive_integer_node(self, symbol_table, factory, node_info, internal_data):
def parse_positive_integer_node(self, factory, symbol_table, node_info, internal_data):
if len(internal_data) != 8:
raise YYASTParserException("Positive integer node should be exactly 64 bit.")

Expand All @@ -105,7 +105,7 @@ def parse_positive_integer_node(self, symbol_table, factory, node_info, internal
node.parsing_done()
return node

def parse_negative_integer_node(self, symbol_table, factory, node_info, internal_data):
def parse_negative_integer_node(self, factory, symbol_table, node_info, internal_data):
if len(internal_data) != 8:
raise YYASTParserException("Negative integer node should be exactly 64 bit.")

Expand All @@ -114,7 +114,7 @@ def parse_negative_integer_node(self, symbol_table, factory, node_info, internal
node.parsing_done()
return node

def parse_binary_float_node(self, symbol_table, factory, node_info, internal_data):
def parse_binary_float_node(self, factory, symbol_table, node_info, internal_data):
if len(internal_data) != 8:
raise YYASTParserException("Binary float node should be exactly 64 bit.")

Expand All @@ -123,16 +123,16 @@ def parse_binary_float_node(self, symbol_table, factory, node_info, internal_dat
node.parsing_done()
return node

def parse_decimal_float_node(self, symbol_table, factory, node_info, internal_data):
def parse_decimal_float_node(self, factory, symbol_table, node_info, internal_data):
if len(internal_data) != 8:
raise YYASTParserException("Decimal float node should not have data.")

raise NotImplementedError("Decimal float is not implemented in the parser.")

def parse_list_node(self, symbol_table, factory, node_info, internal_data):
def parse_list_node(self, factory, symbol_table, node_info, internal_data):
raise NotImplementedError("List node should not exist in the file.")

def parse_count_node(self, symbol_table, factory, node_info, internal_data):
def parse_count_node(self, factory, symbol_table, node_info, internal_data):
raise NotImplementedError("Count node should not exist in the file.")

def parse_node(self, symbol_table, data):
Expand Down

0 comments on commit 2f13a16

Please sign in to comment.