Skip to content

Commit d841e5d

Browse files
committed
fix: integrating the new version of the parsing and solving issues with attributes transformation
1 parent c2b38bf commit d841e5d

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

flamapy/metamodels/fm_metamodel/transformations/uvl_reader.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -356,30 +356,23 @@ def process_expression(self, ctx: Any) -> Node:
356356
# Binary expressions (arithmetics)
357357
# 1. Handle Arithmetic Binary Expressions
358358
arithmetic_ops = {
359-
UVLPythonParser.AddExpressionContext: (ASTOperation.ADD,
360-
'additiveExpression',
361-
'multiplicativeExpression'),
362-
UVLPythonParser.SubExpressionContext: (ASTOperation.SUB,
363-
'additiveExpression',
364-
'multiplicativeExpression'),
365-
UVLPythonParser.MulExpressionContext: (ASTOperation.MUL,
366-
'multiplicativeExpression',
367-
'primaryExpression'),
368-
UVLPythonParser.DivExpressionContext: (ASTOperation.DIV,
369-
'multiplicativeExpression',
370-
'primaryExpression'),
359+
UVLPythonParser.AddExpressionContext: ASTOperation.ADD,
360+
UVLPythonParser.SubExpressionContext: ASTOperation.SUB,
361+
UVLPythonParser.MulExpressionContext: ASTOperation.MUL,
362+
UVLPythonParser.DivExpressionContext: ASTOperation.DIV,
371363
}
372364

373365
ctx_type = type(ctx)
374366
if ctx_type in arithmetic_ops:
375-
op, left_attr, right_attr = arithmetic_ops[ctx_type]
376-
return Node(op, self.process_expression(getattr(ctx, left_attr)()),
377-
self.process_expression(getattr(ctx, right_attr)()))
378-
379-
# 2. Handle grammar fall-through (recursive descent)
380-
for attr in ['additiveExpression', 'multiplicativeExpression', 'primaryExpression']:
381-
if hasattr(ctx, attr):
382-
return self.process_expression(getattr(ctx, attr)())
367+
op = arithmetic_ops[ctx_type]
368+
return Node(op, self.process_expression(ctx.expression(0)),
369+
self.process_expression(ctx.expression(1)))
370+
371+
# 2. Handle single-child expression (grammar fall-through)
372+
if hasattr(ctx, 'expression') and callable(ctx.expression):
373+
child = ctx.expression()
374+
if child is not None:
375+
return self.process_expression(child)
383376

384377
# 3. Delegate leaves to a specialized helper to reduce complexity
385378
return self._process_expression_leaves(ctx)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
flamapy-fw~=2.1.0.dev1
2-
uvlparser~=2.0.1
2+
uvlparser~=2.0.1.dev61
33
afmparser~=1.0.3

0 commit comments

Comments
 (0)