[antlr-interest] tree grammars that output templates
Michael LeBlanc
Mike at leblanc-engineering.com
Fri Oct 19 10:33:14 PDT 2007
Hello, everyone. I'm trying to get up to speed with ANTLR. At this
time my big interest is multi-pass rigs that (re)write trees and
finally output templates. I'm having some trouble with my own
efforts and similar problems with the v3 examples. This leads me to
suspect that I don't have in place some crucial piece of the puzzle.
I'm following the book (A Definitive ANTLR Reference) from page 222,
the section Generating Bytecode Templates with a Tree Grammar. I
downloaded the files and ...
> $ java -Xmx200M org.antlr.Tool *.g
> ANTLR Parser Generator Version 3.0.1 (August 13, 2007) 1989-2007
> Expr.g
> Gen.g
>
> $ javac Test.java
> Test.java:43: incompatible types
> found : java.lang.Object
> required: org.antlr.stringtemplate.StringTemplate
> StringTemplate output = r2.getTemplate();
> ^
> Note: Some input files use unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
> 1 error
Why does this happen? Anyhow, I changed the offending line to read
StringTemplate output = (StringTemplate)r2.getTemplate();
> $ javac Test.java
> Note: Some input files use unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
>
> $ java Test
> 3+4*5
> ^D
> BR.recoverFromMismatchedToken
> line 0:-1 mismatched input '<EOF>' expecting NEWLINE
> Gen.g: node from line 0:0 required (...)+ loop did not match
> anything at input 'EOF'
> Exception in thread "main" java.lang.NullPointerException
> at Test.main(Test.java:44)
I am running on MacOSX 10.4.10 with
> java -version
> java version "1.5.0_07"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
> Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode)
Any ideas?
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071019/726d0096/attachment.html
More information about the antlr-interest
mailing list