Why parser ignores single quotes?

26 views
Skip to first unread message

Eugene Lepekhin

unread,
Dec 31, 2022, 3:46:44 AM12/31/22
to antlr-discussion
Hi,
I have the following lexer file FusionLexer.g4:
lexer grammar FusionLexer;
NumberLiteral: DecNumber;
fragment DecNumber: NonzeroDigit DecDigit*;
fragment DecDigit: [0-9];
fragment NonzeroDigit: [1-9];
Whitespace: [ \t\r\n]+ -> skip;

And the parser file FusionParser.g4:
parser grammar FusionParser;
fusionProgram: number* EOF;
number: NumberLiteral;

When I parse the following text:
'8 '9
'10

I am getting a valid parse tree:
(fusionProgram (number 8) (number 9) (number 10) <EOF>)

Which is puzzling me as I'd expect a syntax error as quotes are not allowed anywhere in the grammar.
Can someone shed some light on what is going on here?
Thanks,
Eugene

Terence Parr

unread,
Jan 2, 2023, 1:03:10 PM1/2/23
to antlr-di...@googlegroups.com
hiya we've moved questions to https://stackoverflow.com/questions/tagged/antlr4  Could you repost there?

In this case, you probably have token errors that are being ignored.

--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/antlr-discussion/aac0f5df-5415-4e05-b7c9-51e43b073217n%40googlegroups.com.


--
Dictation in use. Please excuse homophones, malapropisms, and nonsense.
Reply all
Reply to author
Forward
0 new messages