[antlr-interest] Literals and subrules

Kenneth Domino kenneth.domino at domemtech.com
Fri Feb 26 11:18:00 PST 2010


OK, no response.  So, if anyone is interested, this is a bug my opinion.  A
tool that gives no error message for input then produce a parser
that does not compile is a bug.  If it isn't a valid grammar, which I 
figured
out it isn't, the tool should at least produce an error message.

grammar xxx;

stuff:
        'a' .. 'z' | 'A' .. 'Z'
        ;

The answer was buried deep in the book "The Definitive ANTLR Reference",
ISBN-10: 0-9787392-5-6, Version: 2010-2-4,
page 95 (section Element Sets).  It is only valid for lexers, but was used 
in
a parser context.  So, it's illegal input, but a bug with the tool as well.

As an aside, I wish the book would be more detailed, a specification of
the Antlr language, as detailed as I would see for a major programming 
language,
e.g., C# at
 http://download.microsoft.com/download/3/8/8/388e7205-bc10-4226-b2a8-75351c669b09/CSharp%20Language%20Specification.doc,or for Java at http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf.In both these examples, each terminal and nonterminalin the language is described in gory detail, and a BNF provided in theappendix.There isn't any BNF in the Antlr book, and the descriptions are not detailedenough.  As a result, I have to learn Antlr by trying many small examplesand observing how it works.


More information about the antlr-interest mailing list