dcsimg
What I do with grammar files? Should they have a .g or .txt extension? Why can't the java source file access the recognizer and lexer. PLEASE HELP!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kia_Abdullah
Posted On:   Monday, November 4, 2002 06:49 AM

Hi, I have downloaded the pre-completed Java Grammar from the "Resources and Grammars" section at www.antlr.org. I am new to antlr and was hoping you could help me. There are five files that come with it: * Main.java * tests * java.g (Contains JavaTreeParser) * java.tree.g (Contains JavaRecognizer and JavaLexer) * shiplist (List of file) I have compiled Main.java but it cannot access JavaRecognizer, JavaLexer and JavaTeeParser. This is because I don't know what to do with the grammar files. - Do I leave their names as they are? (java.g and java.tree.g or do I change them to the name of the classes they contain?)    More>>

Hi, I have downloaded the pre-completed Java Grammar from the "Resources and Grammars" section at www.antlr.org. I am new to antlr and was hoping you could help me.


There are five files that come with it:


* Main.java

* tests

* java.g (Contains JavaTreeParser)

* java.tree.g (Contains JavaRecognizer and JavaLexer)

* shiplist (List of file)


I have compiled Main.java but it cannot access JavaRecognizer, JavaLexer and JavaTeeParser. This is because I don't know what to do with the grammar files.


- Do I leave their names as they are? (java.g and java.tree.g or do I change them to the name of the classes they contain?)


- Do I leave them with a .g extension? Windows does not recognise files of this type.


- Do I put them in the same directory as Main.java? The code in Main.java imports the grammars by:
import JavaRecognizer;
import JavaLexer;
but the errors say "class JavaLexer not found" and "class JavaRecognizer not found" etc.


PLEASE tell me what to do with the grammar files. I have tried reading the Reference Manual but it only explains WHAT to put in a grammar file, not what to do with the actual file once you have finished it.


THANK YOU for your time.

Kia

kia76@hotmail.com

   <<Less

Solution

Posted By:   Moe_Moe  
Posted On:   Tuesday, November 12, 2002 04:28 AM

Hi you need to first download ANTLR 2.7.x


copy the source/class files to the same directory


Use the ANTLR tool to compile the java.g file.


That will produce JavaTreeParser.java, JavaRecognizer, JavaLexer.


Once that is done then you can compile the Main.java file.
About | Sitemap | Contact