John Shepard recently wrote about ANTLR4 grammar on his blog.
“In Terrence Parr’s delightfully clear book on ANTLR4, he has an example calculator that uses visitors. I, of course, wondered what a calculator would look like if it used listeners. This is the result.
Here is the grammar. There no longer needs to be recursion for the expression (which was required in earlier version of ANTLR). The priority is now based on the order. Note the comments. These are not optional, and are used for the names of the generated methods.”