1
votes

Here is the grammar file:

grammar fred;
test    :   'fred';

Here is the batch file to launch the tool:

SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
SET PATH=%PATH%;%JAVA_HOME%\bin
SET ANTLR_HOME=c:/users/don/workspace/antlrAssign/lib/
java -cp %ANTLR_HOME%/antlr-3.3-complete.jar  antlr.Tool fred.g

Here's the result:

ANTLR Parser Generator   Version 2.7.7 (20060906)   1989-2005
fred.g:1:1: unexpected token: grammar
error: Token stream error reading grammar(s):
fred.g:3:19: expecting ''', found 'r'
fred.g:1:1: rule grammar trapped:
fred.g:1:1: unexpected token: grammar
TokenStreamException: expecting ''', found 'r'

Prior postings refer to "org.antlr.Tool" but the 3.3 jar has it located as above. The idea was to create a debug version of a tree parser, and according to the documentation, you have to use the command line tool.

Has anyone seen this before? Am I nuts? It's two lines long and its dying on the first word in the file.

Of course this compiles in antlrworks.

Any help appreciated, I can't afford any more adjustments to my medications.

Follow up:

I found that if you use the Run --> Debug menu option in ANTLRWORKS it will produce a debug version of a tree parser, but in my hands the command line tool does not. The debug source produced lives in the output folder for generation. In ANTLRWORKS to get a non debug version use the Generate menu option. Using the debug version of the tree parser in eclipse, fire up the test harness and wait, then connect with ANTRWORKS via Run Remote Debug, on the treegrammar parser file. It walked through the parser for the tree and gave me a mismatched tree node error (not a parser error, which is good because I'm debugging the tree parser). So now I just need to find what other dumb thing I've done. HTH somebody besides me.

1

1 Answers

0
votes

Prior postings refer to "org.antlr.Tool" but the 3.3 jar has it located as above.

The old ANTLR 2.x Tool class (antlr.Tool) is still included in the 3.x version(s) of ANTLR, but you need to use the ANTLR 3.x Tool (located: org.antlr.Tool) for your grammar since it is a 3.x grammar.