Skip to content

Commit

Permalink
Fix parsing of fields with initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ZimM-LostPolygon committed Oct 2, 2023
1 parent 845a04a commit fb92a84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/code_dom/classstructunion.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def parse(context, stream):
if not child_element.no_default_add:
dom_element.add_child(child_element, context)
else:
print("Unrecognised element: " + str(vars(tok)))
print("Unrecognised element: " + str(vars(tok)) + " in DOMClassStructUnion " + dom_element.name)
break

stream.get_token_of_type(['SEMICOLON']) # Eat the trailing semicolon
Expand Down
10 changes: 10 additions & 0 deletions src/code_dom/fielddeclaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ def parse(context, stream):
else:
dom_element.width_specifiers.append(None)

# Check for initializer

if stream.get_token_of_type(['EQUAL']):
while True:
# Skip initializer
next_token = stream.peek_token()
if next_token.type != 'SEMICOLON':
stream.get_token()
break

separator_token = stream.get_token_of_type(["SEMICOLON", "COMMA"])
if separator_token is None:
stream.rewind(checkpoint)
Expand Down
3 changes: 2 additions & 1 deletion src/modifiers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
from . import mod_mark_flags_enums
from . import mod_add_exploded_variadic_functions
from . import mod_add_unformatted_functions
from . import mod_move_types
from . import mod_move_types
from . import mod_remove_typedefs

0 comments on commit fb92a84

Please sign in to comment.