[antlr-interest] unexpected token error in StringTemplate

Warner Onstine warnero at gmail.com
Wed Aug 29 10:56:43 PDT 2007


I've been trying to figure out what the problem is with this (my last
step!) and would appreciate any help. I'm attaching the grammar and
stg file, but will explain with short code here.

I'm getting this error when I run my test:

action parse error in group Java line 35; template context is [select_statement]

line 1:4: unexpected token: crit

The relevant section is this:
select_statement(crit, model) ::= <<
<if (crit != null)>
	<crit>
<else>
getHibernateTemplate().find("from <model>")
<endif>
>>

I cobbled together this syntax as best I could from the ST
documentation (as it isn't really clear on when to use brackets "<>"
vs. the dollar-sign "$" notation.

And in my grammar file:
selectStatement
	:	'Select' '(' ')' criteria=criteriaBlock? ->
select_statement(crit={criteria != null ? $criteria.st : null},
model={$prog::className})
	;
	
The className also appears to not be coming through (the test runs and
outputs even though I have this error. I've tried changing the "crit"
variable to other names but with the same results.

Thanks for all the help!

-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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ModelDAO.stg
Type: application/octet-stream
Size: 1653 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070829/ea040638/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Model.g
Type: application/octet-stream
Size: 2970 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070829/ea040638/attachment-0001.obj 


More information about the antlr-interest mailing list