Skip to content

Commit ee5bd98

Browse files
engalarengalar
authored andcommitted
fix: support @Module.Const syntax in expressions (fixes #178)
Parser now accepts @QualifiedName as a constant reference in any expression context (DECLARE, SET, CHANGE, etc.), matching the output of DESCRIBE MICROFLOW. This restores the round-trip guarantee: DESCRIBE output can be fed back into CREATE without modification.
1 parent 503cfb6 commit ee5bd98

File tree

9 files changed

+802
-761
lines changed

9 files changed

+802
-761
lines changed

mdl/ast/ast_expression.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ type QualifiedNameExpr struct {
108108

109109
func (e *QualifiedNameExpr) isExpression() {}
110110

111+
// ConstantRefExpr represents a constant reference: @Module.ConstantName
112+
type ConstantRefExpr struct {
113+
QualifiedName QualifiedName // The constant qualified name
114+
}
115+
116+
func (e *ConstantRefExpr) isExpression() {}
117+
111118
// IfThenElseExpr represents an inline if-then-else expression:
112119
// if condition then trueExpr else falseExpr
113120
type IfThenElseExpr struct {

mdl/executor/cmd_microflows_helpers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ func expressionToString(expr ast.Expression) string {
130130
case *ast.QualifiedNameExpr:
131131
// Qualified name (association name, entity reference) - unquoted
132132
return e.QualifiedName.String()
133+
case *ast.ConstantRefExpr:
134+
return "@" + e.QualifiedName.String()
133135
case *ast.IfThenElseExpr:
134136
cond := expressionToString(e.Condition)
135137
thenStr := expressionToString(e.ThenExpr)

mdl/grammar/MDLParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,7 @@ argumentList
34803480
atomicExpression
34813481
: literal
34823482
| VARIABLE (DOT attributeName)* // $Var or $Widget.Attribute (data source ref)
3483+
| AT qualifiedName // @Module.ConstantName (constant reference)
34833484
| qualifiedName
34843485
| IDENTIFIER
34853486
| MENDIX_TOKEN

mdl/grammar/parser/MDLParser.interp

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

mdl/grammar/parser/mdl_lexer.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdl_parser.go

Lines changed: 779 additions & 757 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdlparser_base_listener.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdlparser_listener.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/visitor/visitor_microflow_expression.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,15 @@ func buildAtomicExpression(ctx parser.IAtomicExpressionContext) ast.Expression {
617617
}
618618
}
619619

620+
// Constant reference: @Module.ConstantName
621+
if atomCtx.AT() != nil {
622+
if qn := atomCtx.QualifiedName(); qn != nil {
623+
return &ast.ConstantRefExpr{
624+
QualifiedName: buildQualifiedName(qn),
625+
}
626+
}
627+
}
628+
620629
// Mendix token [%TokenName%]
621630
if token := atomCtx.MENDIX_TOKEN(); token != nil {
622631
tokenText := token.GetText()

0 commit comments

Comments
 (0)