[antlr-interest] Class instead of grammar and feeding grammars

Loring Craymer lgcraymer at yahoo.com
Tue Aug 7 01:04:52 PDT 2012


You have both ANTLR 2 and ANTLR 3 grammars:  "class" is used for ANTLR 2 grammars, and "grammar" for ANTLR 3.  ANTLR 2 and ANTLR 3 are different tools and have different libraries.

--Loring



>________________________________
> From: Oana Ureche <oana_ureche2000 at yahoo.com>
>To: "antlr-interest at antlr.org" <antlr-interest at antlr.org> 
>Sent: Monday, August 6, 2012 11:03 PM
>Subject: [antlr-interest] Class instead of grammar and feeding grammars
> 
>Hi all,
>
>Could I please ask your clarification on two matters? I am a newbie so sorry in advance.
>
>I am trying to convert source code to XML which I have been successful with PHP, but I think it was by luck, because I can't seem to do it for Java. 
>While trying to, I have encountered two things...
>
>I have noticed that some grammars start with class instead of grammar, such as:
>class JavaRecognizer extends Parser;
>options { ...
>} and thus I am having errors when trying to generate the Java file:
>
>C:\>java -cp antlrworks-1.4.3.jar org.antlr.Tool java15.g
>error(10):  internal error:  : java.lang.Error: Error parsing java15.g: 'class'
>not expected 'grammar'
>
>So I am curious what is the difference and how am I going to get the Java generated file?
>
>Second, I have noticed that some Java grammars have two files, such as: Java.g and JavaParserTree.g and I have ran into the concept of  "a tree grammar that can be fed with the Java.g grammer's output." How do I "feed" the grammar exactly? Do I first generate the Java files and do the feeding in the file that processes the output? For example, 
>
>CommonTokenStream tokens = new CommonTokenStream(lexer); //lexer generated from Java.g
>JavaTreeParser parser = new JavaTreeParser(tokens); 
>
>Thank you very much in advance,
>oanure
>
>List: http://www.antlr.org/mailman/listinfo/antlr-interest
>Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>


More information about the antlr-interest mailing list