[antlr-interest] stuck on templates
Warner Onstine
warnero at gmail.com
Mon Aug 27 10:48:05 PDT 2007
I've been reading through the book and the CMinus example included in
the v3 zip example set and I must be missing something because I can't
get anything to work at all.
Here is what I gathered from the book and from the site and
(hopefully) you can tell me where my mistake is.
First a rule like this:
packageDecl
: 'package' name=QID
;
can be translated to something like this:
packageDecl
: 'package' name=QID -> package_name(name=name.text)
;
Where package_name() is declared in my stg file like this:
package_name ::= "package <name>;"
Is this right? If so, why do I keep getting an error in ANTLRWorks
saying "Undefined reference 'package_name'".
I also tried to do something similar to the CMinus example here:
program
scope {
List globals;
List functions;
}
@init {
$program::globals = new ArrayList();
$program::functions = new ArrayList();
}
But when I did that ANTLRWorks first complains about "program" being
defined already (in the @init section) and it then complains about not
finding ArrayList (even though I added it in the @header section.
Thanks for any help, just trying to wrap my head around this stuff.
-warner
--
Warner Onstine - Programmer/Author
New book on Tapestry 4!
Tapestry 101 available at
http://sourcebeat.com/books/tapestrylive.html
warner at warneronstine.com
http://warneronstine.com/blog
More information about the antlr-interest
mailing list