[antlr-interest] Grammar, ANTLRWorks and ANTLR problems

Terence Parr parrt at cs.usfca.edu
Thu Mar 29 17:09:28 PDT 2007


On Mar 29, 2007, at 2:37 PM, Johannes Luber wrote:

> Hello,
>
> while I was busy studying the Beta Book, I've stumbled upon the  
> follwing
> grammar rule on page 223:
>
> stat:  expr -> exprStat(v={$expr.st}, descr={$expr.text})
>     |  ^( '=' IDexpr)
>        -> assign(id={$ID.text},
>                  descr={$text},
>                  varNum={locals.get($ID.text)},
>                  v={$expr.st})
>     ;
>
> The strange part is that I can't see, where $text comes from. I wanted
> to compile the files first before I had mentioned this, but that was
> where my problems started.

$text is the text for the rule.  actually it's the text of the first  
tree matched.

> I downloaded both 2-pass grammars from the website and proceeded to
> generate them with ANTLRWorks. I've changed the output path to
> "D:\Studium\Compilerbau\ANTLR\2pass" and generated Expr.g without
> problems. But when I tried to generate Gen.g, ANTLRWorks complained  
> that
> it can't find "tokens file
> D:\Studium\Compilerbau\ANTLR\2pass\Expr.tokens". Strangely the path  
> and
> file name are fully correct.
>
> So I decided to manually compile those grammars. But then I get the
> following message:
>
> "D:\Studium\Compilerbau\ANTLR\2pass>java org.antlr.Tool Expr.g
> no such locale file org/antlr/tool/templates/messages/languages/de.stg
> retrying with English locale
> Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ 
> TokenStream
>         at org.antlr.tool.ErrorManager.setLocale(ErrorManager.java: 
> 392)
>         at org.antlr.tool.ErrorManager.setLocale(ErrorManager.java: 
> 386)
>         at org.antlr.tool.ErrorManager.<clinit>(ErrorManager.java:354)
>         at org.antlr.Tool.main(Tool.java:66)"
>
> What went here all wrong?

add antlr-2.7.7.jar to your classpath.  should be in antlr/lib dir.

Ter



More information about the antlr-interest mailing list