--
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.
For more options, visit https://groups.google.com/d/optout.
For the example you posted here, you did not define WHITESPACE_CHANNEL in the lexer grammar, which resulted in two issues:
1. Warning 155, which is produced by the ANTLR Tool. This warning appeared because you used a lexer command which referenced a constant value WHITESPACE_CHANNEL which ANTLR does not recognize, and therefore does not know what integer value it represents. You defined WHITESPACE_CHANNEL as a token in the ForTest.g4 grammar, but they would need to be in Symbols.g4 in order to be recognized.
2. The compilation error when you tried to compile the generated parser. In this case, javac also did not recognize WHITESPACE_CHANNEL because you did not define the token in your lexer grammar.
Rather than create a “grammar ForTest;” which imports Symbols, you should instead create a grammar which starts with the following:
parser grammar ForTest;
options {
tokenVocab = Symbols;
}
You should then move the tokens{} block from ForTest.g4 to Symbols.g4.
Sam
--
Please refer to the following issue for more information about the requirement that you create separate lexer and parser grammars (at least until this issue is resolved).
#338: tokens section in combined grammar files can't work
Sam
--
Thanks for the reply Mr. TerenceNo my grammar is not small it is spread over 32 files as small snippets.but to reproduce unrecognised token warning i cut it down to testing level. it has some symbols and channel tokens are not being recognisedi must be doing something silly!In the Zip attachment there are three file
- Png snapshot showing error at cmd prompt
- ForTest.g4 which is importing Lexer Symbols
- Symbols.g4 Lexer grammar where -> channel ( LineComment_channel ) ; are used
ThanksRegardsRight_Then
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.
For more options, visit https://groups.google.com/d/optout.
<ErrorWithChannelTokenConstants.7z>