[antlr-interest] Predicate Syntax Problem
Terence Parr
parrt at cs.usfca.edu
Fri Jan 12 11:45:09 PST 2007
> I'll try the latest jar. I want to validate, but having slept on it
> I'm not sure what the advantage of putting this in the parser
> itself is. What I do is build an AST that I pass to a code
> generator (just some Java code that uses StringTemplate directly,
> and that code generator could do the same validation, print out
> nice error messages, kill the build, etc. I get the feeling there's
> some cool way to use StringTemplate with ANTLR 3 that I don't know
> about. If there is and there's some documentation somewhere, please
> point me to it.
Yeah I like doing validation in random java code not with sem preds.
doc: http://www.antlr.org/wiki/display/ANTLR3/Template+construction
You can use -> template construction in either parser or tree
parser. There's a new undocumented mode (only in book so far) called
rewrite=true that uses templates to update the input token buffer in-
place. you can then just toString the buffer to see the altered
buffer. :) Probably not what you want in this case...
> I thought in the ANTLR 2 docs that validation predicates went *not*
> on the left. I've been trying to guess how ANTLR 3 works from
> ANTLR2 docs.
Actually all preds validate but some get hoisted to disambiguate. :)
> Thanks. Really great stuff. I'm just quite the newbie.
Great!
Ter
More information about the antlr-interest
mailing list