Where to know such keywords as EOF in Antlr4 language?

733 views Asked by At

I know Antlr4 has EOF keyword to denote end of file.

Where to see full list of such keywords?

I don't see EOF here: https://github.com/antlr/antlr4/blob/master/doc/lexer-rules.md

3

There are 3 answers

0
Mike Lischke On

EOF is not a keyword but a token value. There are only very few such predefined valus and the best place to spot them is probably the source code. There is:

  • EOF (the only predefined token value)
  • DEFAULT_TOKEN_CHANNEL (the main channel to put tokens in)
  • HIDDEN (the channel for hidden tokens, used often for whitespaces + comments).
  • DEFAULT_MODE (the initial + main lexer mode)
2
GRosenberg On

While, the free online documentation can be a bit sparse, the relevant section is start-rules-and-eof.

Other resources include Parr's book TDAR -- highly recommended, the ANTLR4 grammar itself, and the other sample grammars in that repo.

1
Ivan Kochurkin On

All ANTLR reserved keyword names listed in LexerATNFactory.java file.