Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
romanfedyniak committed Jan 4, 2024
1 parent 7a32e26 commit c68199a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,12 +1560,14 @@ def gen_parsing_expr_rule_name(self, node: ParsingExpressionRuleNameNode, next:
code += " position = __tempMark;\n"
code += "}\n"
elif node.ctx.optional:
code += "{\n"
if node.ctx.name:
var = f"std::optional<{return_type.raw_type}> {node.ctx.name};"
code += "auto __result = "
code += f"(rule__{node.name}());\n"
code += " auto __result = "
code += f" (rule__{node.name}());\n"
if node.ctx.name:
code += f"if (__result) {node.ctx.name} = __result{return_type.getter};\n"
code += f" if (__result) {node.ctx.name} = __result{return_type.getter};\n"
code += "}\n"
elif node.ctx.loop:
if node.ctx.name:
var = f"std::vector<{return_type.raw_type}> {node.ctx.name};"
Expand Down

0 comments on commit c68199a

Please sign in to comment.