I am creating a new new grammar file for Natural-adabas Language. As a starting point I have relied on ChatGPT for generating the initial grammar syntax.
I am facing an issue in the below, as the addOperation
is not correctly breaking on EOL
or newLine
and its incorrectly going further over the code
addOperation
: ADD .*? (END_OF_LINE)
;
code snippet
7740 IF TURN-ON-MISC-PAY-FORM-IND(7730) = 'Y' THEN DO
7750 ADD 1 TO #B
7760 RESET #MISC-TRANSACTION-ENTRY
Tried multiple combinations of end of line or new line characters in the lexer file.
The .*
inside a parser does not match what a .*
inside a lexer rule matches. Inside a lexer rule it matches zero or more characters, but inside a parser rule, it matches zero or more tokens. So if 1 TO #B
is not handled by any lexer rule, the parser rule addOperation
will not match the input. Besides that, a .*
inside a parser rule is (usually) a bad idea to begin with.
As a starting point I have relied on ChatGPT for generating the initial grammar syntax.
I recommend really learning ANTLR instead of “learning” from an AI model.