I've got a basic ANTLR-4 grammar at the moment in my Eclipse IDE for Java, and have the following:
// Parser
importDeclaration:
'use' name=FQN ';'
;
// Lexer and terminals
fragment LETTER: [a-zA-Z_];
fragment LETTER_OR_DIGIT: [a-zA-Z0-9_];
ID: LETTER LETTER_OR_DIGIT*;
FQN: ID ('.' ID)*;
WS: [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
COMMENT: '/*' .*? '*/' -> channel(HIDDEN);
LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN);
Hopefully a short and sweet question, when I do the following:
use test;
I get:
line 1:4 mismatched input 'test' expecting FQN
And name
throws a NullPointerException
if I try to use it.
Except it works fine when I do:
use test.test;
This has to do with the ('.' ID)*
portion, but have no idea why it's happening.
Any ideas?
Edit:
Just realised my code was wrong, had (FQN|ID)
which was my bad workaround. Fixed it now.