You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2008/10/15 00:01:47 UTC

[jira] Commented: (VELOCITY-631) VTL Creates parse error, but shouldn't

    [ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12639613#action_12639613 ] 

Nathan Bubna commented on VELOCITY-631:
---------------------------------------

I'm messing around with this off and on today, though i'm anything but an expert on the parser.   It looks like putting a space between the reference and the #set is a perfect workaround, as #set then gobbles that space up.  Here's some perhaps useful debug output from my latest version of the test (with ParserTokenManager.debugPrint = true).  If anyone more parser-savvy happens to read this and have an insight, that would be swell...

Running org.apache.velocity.test.issues.Velocity631TestCase
  [info] Expectation: $a
  [info] Template: $a #set($b = 1)
$  : going to 5 (0) pushing cur state : 3
REF_TERM : stack pop (0) : lparen=0 newstate=3
#set :  going to 0 (0) pushing cur state : 3
$  : going to 5 (1) pushing cur state : 0
REF_TERM : stack pop (1) : lparen=1 newstate=0
 stack pop (0) : lparen=0 newstate=3
  [info] Result: $a

  [info] Expectation: $a
  [info] Template: $a#set($b = 1)
$  : going to 5 (0) pushing cur state : 3
 stack pop (0) : lparen=0 newstate=3
# :  going to 0 (0) pushing cur state : 3
$  : going to 5 (1) pushing cur state : 0
REF_TERM : stack pop (1) : lparen=1 newstate=0
 [error] Parser Exception: $a#set($b = 1)
Encountered "=" at line 1, column 11.
Was expecting:
    <RPAREN> ...

org.apache.velocity.runtime.parser.ParseException: Encountered "=" at line 1, column 11.
Was expecting:
    <RPAREN> ...

    at org.apache.velocity.runtime.parser.Parser.generateParseException(Parser.java:3437)
    at org.apache.velocity.runtime.parser.Parser.jj_consume_token(Parser.java:3316)
    at org.apache.velocity.runtime.parser.Parser.Directive(Parser.java:833)
    at org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:373)
    at org.apache.velocity.runtime.parser.Parser.process(Parser.java:311)
    at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:105)

I can see that the $a#set version is not recognizing the #set, but i don't know how to fix that...

> VTL Creates parse error, but shouldn't
> --------------------------------------
>
>                 Key: VELOCITY-631
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-631
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.6-beta1
>            Reporter: Byron Foster
>         Attachments: Velocity631TestCase.java
>
>
> The following creates a parse exception, but should not:
> #macro(test $x)$x#set($i=1)#end
> Exception:
> Threw: org.apache.velocity.exception.ParseErrorException
> msg: Encountered "=" at /foo.vm[line 2, column 25]
> Was expecting one of:
>     <RPAREN> ...
>     <WHITESPACE> ...
>     <WHITESPACE> ...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org