[antlr-interest] Class instead of grammar and feeding grammars
Oana Ureche
oana_ureche2000 at yahoo.com
Mon Aug 6 23:03:07 PDT 2012
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
More information about the antlr-interest
mailing list