Skip to content

Commit f31fa1b

Browse files
committed
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 c97c85b commit f31fa1b

File tree

9 files changed

+408
-368
lines changed

9 files changed

+408
-368
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
@@ -129,6 +129,8 @@ func expressionToString(expr ast.Expression) string {
129129
case *ast.QualifiedNameExpr:
130130
// Qualified name (association name, entity reference) - unquoted
131131
return e.QualifiedName.String()
132+
case *ast.ConstantRefExpr:
133+
return "@" + e.QualifiedName.String()
132134
case *ast.IfThenElseExpr:
133135
cond := expressionToString(e.Condition)
134136
thenStr := expressionToString(e.ThenExpr)

mdl/grammar/MDLParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3435,6 +3435,7 @@ argumentList
34353435
atomicExpression
34363436
: literal
34373437
| VARIABLE (DOT attributeName)* // $Var or $Widget.Attribute (data source ref)
3438+
| AT qualifiedName // @Module.ConstantName (constant reference)
34383439
| qualifiedName
34393440
| IDENTIFIER
34403441
| 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: 385 additions & 364 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
@@ -614,6 +614,15 @@ func buildAtomicExpression(ctx parser.IAtomicExpressionContext) ast.Expression {
614614
}
615615
}
616616

617+
// Constant reference: @Module.ConstantName
618+
if atomCtx.AT() != nil {
619+
if qn := atomCtx.QualifiedName(); qn != nil {
620+
return &ast.ConstantRefExpr{
621+
QualifiedName: buildQualifiedName(qn),
622+
}
623+
}
624+
}
625+
617626
// Mendix token [%TokenName%]
618627
if token := atomCtx.MENDIX_TOKEN(); token != nil {
619628
tokenText := token.GetText()

0 commit comments

Comments
 (0)