Antlr question: cannot get Antlr tool to compile simple file from ANTLRWorks

Posted by Don Henton on Stack Overflow See other posts from Stack Overflow or by Don Henton
Published on 2011-03-20T02:14:27Z Indexed on 2011/03/20 8:09 UTC
Read the original article Hit count: 680

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about antlr

Related posts about antlr3