I created a file MyLexer.g4
inside myproject/src/main/antlr/com/mypackage
like:
lexer grammar MyLexer;
DIGIT : '0' .. '9' ;
...
WS : [ \t\r\n]+ -> skip ;
and then trying to write parser in MyParser.g4
in the same directory:
grammar MyParser;
options
{ tokenVocab = MyLexer; }
SHORT_YEAR: DIGIT DIGIT;
unfortunately, when I run gradle task of generateGrammarSource
, the following error occurs:
error(160): com\mypackage\MyParser.g4:4:18: cannot find tokens file MYPROJECT\build\generated-src\antlr\main\MyLexer.tokens
I.e. file is sought in incorrect place.
Actual file is created inside MYPROJECT\build\generated-src\antlr\main\com\mypackage\MyLexer.tokens