File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/main/java/com/alibaba/qlexpress4/aparser Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -185,16 +185,23 @@ public Void visitBlockStatements(BlockStatementsContext blockStatementsContext)
185185 .filter (bs -> !(bs instanceof EmptyStatementContext ))
186186 .collect (Collectors .toList ());
187187
188- // First pass: process all function definitions to support forward references
188+ // First pass: process macro definitions to ensure they are available for functions
189+ for (BlockStatementContext child : nonEmptyChildren ) {
190+ if (child instanceof MacroStatementContext ) {
191+ child .accept (this );
192+ }
193+ }
194+
195+ // Second pass: process all function definitions to support forward references
189196 for (BlockStatementContext child : nonEmptyChildren ) {
190197 if (child instanceof FunctionStatementContext ) {
191198 child .accept (this );
192199 }
193200 }
194201
195- // Second pass: process all non-function statements
202+ // Third pass: process all other statements
196203 for (BlockStatementContext child : nonEmptyChildren ) {
197- if (!(child instanceof FunctionStatementContext )) {
204+ if (!(child instanceof FunctionStatementContext ) && !( child instanceof MacroStatementContext ) ) {
198205 if (isPreExpress ) {
199206 addInstruction (new PopInstruction (PureErrReporter .INSTANCE ));
200207 }
You can’t perform that action at this time.
0 commit comments