[antlr-interest] How to separate lexer and parser? How to invoke ANTLR?

Terence Parr parrt at cs.usfca.edu
Mon May 28 18:35:57 PDT 2007


Hi David,

did you say "lexer grammar foo" or just "grammar foo"?  Need a  
"parser grammar foo" and "lexer grammar foo" in separate files.

Ter
On May 28, 2007, at 6:32 PM, David Piepgrass wrote:

> I know v3 has combined grammars, but I want a separate lexer and  
> parser. However, when I try to compile a grammar without a parser,  
> ANTRLWorks says
>
> >  Cannot generate the grammar because
> >  (100): D:\...\Test.g:0:0: syntax error: codegen: <AST>:0:0:  
> unexpected end of subtree
>
> Ideas?
>
> I would also like to manually control the numeric IDs for token  
> types, in order to share some of the same numbers between multiple  
> lexers; how can I do this?
>
> Also, how do I invoke antlr-3.0.jar from the command line? The book  
> says to use
>
> java org.antlr.Tool Test.g
>
> which I changed to
>
> java -classpath antlr-3.0.jar org.antlr.Tool Test.g
>
> but I got the error
>
> >  Exception in thread "main" java.lang.NoClassDefFoundError: org/ 
> antlr/stringtemplate/StringTemplateErrorListener
> >        at org.antlr.Tool.main(Tool.java:67)
>
> Forgive me, I'm not a Java guy. How can I make it work?
> -- 
> - David
> http://qism.blogspot.com



More information about the antlr-interest mailing list