[antlr-interest] Grammar, ANTLRWorks and ANTLR problems

Johannes Luber jaluber at gmx.de
Thu Mar 29 14:37:46 PDT 2007


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.

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?

Best regards,
Johannes Luber



More information about the antlr-interest mailing list