Open diyan-gochev-at-ft-dot-com opened 2 months ago
It could be as designed. But, we need to actually see a minimum reproducible example (grammar and input). Check whether your start rule is a proper EOF-terminated rule. It should be.
@kaby76 Thank you for your feedback. The case is very simple, I have 2 rules:
pathExpression
: IDENTIFICATION_VARIABLE ('.' IDENTIFICATION_VARIABLE)*
;
AND
functionsReturningNumerics
: 'LENGTH' '(' stringPrimary ')'
| 'LOCATE' '(' ....
with options:
options { caseInsensitive = true; }
The string to parse (the subject) is the string:
id,name,type,palletType,length,width,height
(does not contain parentheses at all).
I expect functionsReturningNumerics rule to fail to match because of the missing (but required parentheses) and continue trying to match the other rules, and eventually match "pathExpression", but instead, ANTLR logs
line 1:30 mismatched input ',' expecting '('
and even though the parentheses are missing, the parser successfully matches functionsReturningNumerics. Here is the log, showing that "functionsReturningNumerics" rule succeeds:
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : visitTerminal(,)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : visitTerminal(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitFunctionsReturningNumerics(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitArithmeticPrimary(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitArithmeticFactor(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitArithmeticTerm(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitSimpleArithmeticExpression(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitArithmeticExpression(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitExpression(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : exitSelectExpressionWithAlias(length)
2024-09-18T04:38:46.974+03:00 INFO 62114 --- [nio-8080-exec-2] c.etradesoft.aql.parser.AQLListenerImpl : visitTerminal(,)
The problem is that functionsReturningNumerics rule succeeds without the required parentheses.
The comment has been updated, the logs provided. Looks like a bug.
I am using ANTLR 4.13.2
........
passing just 'LENGTH' without parentheses, ANTLR matches the expression. Is it an expected behaviour or it's bug?