Skip to content

Commit

Permalink
fix bug with inline attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
romanfedyniak committed Jan 4, 2024
1 parent c68199a commit ac9261f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,8 +1463,8 @@ def gen_parsing_expr(
for i in node.items:
match i:
case ParsingExpressionRuleNameNode():
if (rule := self.ctx.get_rule_by_name(i.name)).inline: # type: ignore
group = ParsingExpressionGroupNode(rule.expression_sequences)
if (rule_ := self.ctx.get_rule_by_name(i.name)) and rule_.inline:
group = ParsingExpressionGroupNode(rule_.expression_sequences)
group.ctx = i.ctx
generated_exprs.append(self.gen_parsing_expr_group(group, next, f"group_{expr_index}_{group_index}"))
group_index += 1
Expand Down Expand Up @@ -1770,7 +1770,13 @@ def gen_parsing_expr_inside_group(
for i in node.items:
match i:
case ParsingExpressionRuleNameNode():
generated_exprs.append(self.gen_parsing_expr_rule_name(i, next))
if (rule := self.ctx.get_rule_by_name(i.name)) and rule.inline:
group = ParsingExpressionGroupNode(rule.expression_sequences)
group.ctx = i.ctx
generated_exprs.append(self.gen_parsing_expr_group(group, next, f"{prefix}_{expr_index}_{group_index}"))
group_index += 1
else:
generated_exprs.append(self.gen_parsing_expr_rule_name(i, next))
case ParsingExpressionStringNode():
generated_exprs.append(self.gen_parsing_expr_string(i, next))
case ParsingExpressionCharacterClassNode():
Expand Down

0 comments on commit ac9261f

Please sign in to comment.