Antlr - Generated class

About

From the grammar

  1. The lexer rules will create the lexer class
  2. The parser rules will create the parser class

The classes generated will contain a method for each rule in the grammar.

See example

Example

from the getting started with the below Hello grammar

grammar Hello; 
r  : 'hello' ID ; 
ID : [a-z]+ ; 
WS : [ \t\r\n]+ -> skip ; 
antlr4 Hello.g4

Next to the grammar file, you got:

  • the lexer HelloLexer.java - to create the tokens
  • the parser HelloParser.java - to build the tree
  • the listener HelloListener.java - to traverse the tree
ls -A1
Hello.g4
Hello.interp
Hello.tokens
HelloBaseListener.java
HelloLexer.interp
HelloLexer.java
HelloLexer.tokens
HelloListener.java
HelloParser.java

Powered by ComboStrap