From ac9261f35bb0a5d10b48bc06f34c6b1e71811025 Mon Sep 17 00:00:00 2001 From: romanfedyniak Date: Thu, 4 Jan 2024 20:34:11 +0200 Subject: [PATCH] fix bug with inline attribute --- pparser.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pparser.py b/pparser.py index 59f11fd..b96f825 100644 --- a/pparser.py +++ b/pparser.py @@ -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 @@ -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():