You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Byron Foster (JIRA)" <de...@velocity.apache.org> on 2008/10/14 10:23:44 UTC
[jira] Created: (VELOCITY-631) VTL Creates parse error, but
shouldn't
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
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
[jira] Commented: (VELOCITY-631) VTL Creates parse error, but
shouldn't
Posted by "Byron Foster (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640502#action_12640502 ]
Byron Foster commented on VELOCITY-631:
---------------------------------------
I looked into it, but it's kind of nasty. It appears to be a problem in the grammer. the LOOKAHEAD(2) for a Reference is forcing the tokenizer to interpret the next token after the reference as a WORD instead of a SET_DIRECTIVE (This is happening when the parser is testing for the DOT token). Because it's interpreted as a WORD the rest is interpreted as a directive, which of course doesn't allow "=". I don't know enough about javacc to make the changes, and this kind of stuff is delicate :) Maybe someone more familiar with javacc and the grammer can pick this up.
> 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
> Priority: Minor
> Fix For: 1.6
>
> 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
[jira] Updated: (VELOCITY-631) VTL Creates parse error, but
shouldn't
Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nathan Bubna updated VELOCITY-631:
----------------------------------
Priority: Minor (was: Major)
Fix Version/s: 1.6
Would be nice to fix this for 1.6...
> 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
> Priority: Minor
> Fix For: 1.6
>
> 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
[jira] Resolved: (VELOCITY-631) VTL Creates parse error, but
shouldn't
Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nathan Bubna resolved VELOCITY-631.
-----------------------------------
Resolution: Fixed
Awesome. Thanks, Byron!
> 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
> Priority: Minor
> Fix For: 1.6
>
> Attachments: fix631.patch, 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
[jira] Issue Comment Edited: (VELOCITY-631) VTL Creates parse
error, but shouldn't
Posted by "Byron Foster (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640759#action_12640759 ]
byronvf edited comment on VELOCITY-631 at 10/18/08 3:00 AM:
-----------------------------------------------------------------
Ok, here's a fix. the issue from the comments I added to Parser.jjt:
I added the lexical states REFERENCE, REFMODIFIER, REFMOD2 to the SET_DIRECTIVE. With SET_DIRECTIVE only in the DEFAULT lexical state the following VTL fails "a$#set(b$ = 1)" because the Reference token uses LOOKAHEAD(2) combined with the fact that we explicity set the lex state to REFERENCE with the $ token, which means we would never evaulate this token during the look ahead. This general issue is disscussed here:
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-ie.htm#tth_sEc3.12
The patch looks scarier then it really is because most of it is regenerated files. The only explicit changes is the addition of the attached TestCase, and a change to src/parser/Parser.jjt
was (Author: byronvf):
Ok, here's a fix. the issue from the comments I added to Parser.jjt:
I added the lexical states REFERENCE, REFMODIFIER, REFMOD2 to the SET_DIRECTIVE. With SET_DIRECTIVE only in the DEFAULT lexical state the following VTL fails "a$#set(b$ = 1)" because the Reference token uses LOOKAHEAD(2) combined with the fact that we explicity set the lex state to REFERENCE with the $ token, which means we would never evaulate this token during the look ahead. This general issue is disscussed here:
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-ie.htm#tth_sEc3.12
The patch is looks scarier then it really is because most of are regenerated files. The only explicit changes is the addition of the attached TestCase, and a change to src/parser/Parser.jjt
> 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
> Priority: Minor
> Fix For: 1.6
>
> Attachments: fix631.patch, 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
[jira] Issue Comment Edited: (VELOCITY-631) VTL Creates parse
error, but shouldn't
Posted by "Byron Foster (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640759#action_12640759 ]
byronvf edited comment on VELOCITY-631 at 10/18/08 3:03 AM:
-----------------------------------------------------------------
Ok, here's a fix. the issue from the comments I added to Parser.jjt:
I added the lexical states REFERENCE, REFMODIFIER, REFMOD2 to the SET_DIRECTIVE. With SET_DIRECTIVE only in the DEFAULT lexical state the following VTL fails "a$#set(b$ = 1)" because the Reference token uses LOOKAHEAD(2) combined with the fact that we explicity set the lex state to REFERENCE with the $ token, which means we would never evaulate the SET_DIRECTIVE token during the look ahead. This general issue is disscussed here:
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-ie.htm#tth_sEc3.12
The patch looks scarier then it really is because most of it is regenerated files. The only explicit changes is the addition of the attached TestCase, and a change to src/parser/Parser.jjt
was (Author: byronvf):
Ok, here's a fix. the issue from the comments I added to Parser.jjt:
I added the lexical states REFERENCE, REFMODIFIER, REFMOD2 to the SET_DIRECTIVE. With SET_DIRECTIVE only in the DEFAULT lexical state the following VTL fails "a$#set(b$ = 1)" because the Reference token uses LOOKAHEAD(2) combined with the fact that we explicity set the lex state to REFERENCE with the $ token, which means we would never evaulate this token during the look ahead. This general issue is disscussed here:
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-ie.htm#tth_sEc3.12
The patch looks scarier then it really is because most of it is regenerated files. The only explicit changes is the addition of the attached TestCase, and a change to src/parser/Parser.jjt
> 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
> Priority: Minor
> Fix For: 1.6
>
> Attachments: fix631.patch, 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
[jira] Commented: (VELOCITY-631) VTL Creates parse error, but
shouldn't
Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
[ 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
[jira] Updated: (VELOCITY-631) VTL Creates parse error, but
shouldn't
Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nathan Bubna updated VELOCITY-631:
----------------------------------
Attachment: Velocity631TestCase.java
Here's a test case with an even simpler template to demonstrate the problem.
$a#set($b = 1)
is all it takes.
> 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
[jira] Updated: (VELOCITY-631) VTL Creates parse error, but
shouldn't
Posted by "Byron Foster (JIRA)" <de...@velocity.apache.org>.
[ https://issues.apache.org/jira/browse/VELOCITY-631?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Byron Foster updated VELOCITY-631:
----------------------------------
Attachment: fix631.patch
Ok, here's a fix. the issue from the comments I added to Parser.jjt:
I added the lexical states REFERENCE, REFMODIFIER, REFMOD2 to the SET_DIRECTIVE. With SET_DIRECTIVE only in the DEFAULT lexical state the following VTL fails "a$#set(b$ = 1)" because the Reference token uses LOOKAHEAD(2) combined with the fact that we explicity set the lex state to REFERENCE with the $ token, which means we would never evaulate this token during the look ahead. This general issue is disscussed here:
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-ie.htm#tth_sEc3.12
The patch is looks scarier then it really is because most of are regenerated files. The only explicit changes is the addition of the attached TestCase, and a change to src/parser/Parser.jjt
> 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
> Priority: Minor
> Fix For: 1.6
>
> Attachments: fix631.patch, 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