You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dmitri Blinov (JIRA)" <ji...@apache.org> on 2019/05/21 12:12:00 UTC
[jira] [Comment Edited] (JEXL-303) Block syntax is broken
[ https://issues.apache.org/jira/browse/JEXL-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16844763#comment-16844763 ]
Dmitri Blinov edited comment on JEXL-303 at 5/21/19 12:11 PM:
--------------------------------------------------------------
I can't figure it out, but for some reason the following grammar lookahead seems not to work in the failing case
{code:java}
void Statement() #void : {}
{
...
| LOOKAHEAD(<LCURLY> Statement() <SEMICOL>) Block() // to disambiguate the set literals
...
}
{code}
Things get fixed when I change the grammar to the following
{code:java}
void StatementLookahead() #void : {}
{
<SEMICOL> | <IF> | <FOR> | <DO> | <WHILE> | <RETURN> | <BREAK> | <CONTINUE> | <VAR>
}
void Statement() #void : {}
{
...
| LOOKAHEAD(<LCURLY> StatementLookahead()) Block() // to disambiguate the set literals
...
}
{code}
Hope this helps...
was (Author: dmitri_blinov):
I can't figure it out, but for some reason the following grammar lookahead seems not to work in the failing case
{code:java}
void Statement() #void : {}
{
...
| LOOKAHEAD(<LCURLY> Statement() <SEMICOL>) Block() // to disambiguate the set literals
...
}
{code}
Things get fixed when I change the grammar to the following
{code:java}
void StatementLookahead() #void : {}
{
<SEMICOL> | <IF> | <FOR> | <DO> | <WHILE> | <RETURN> | <BREAK> | <CONTINUE> | <VAR>
}
void Statement() #void : {}
{
...
| LOOKAHEAD(<LCURLY> StatementLookahead()) Block() // to disambiguate the set literals
| LOOKAHEAD(<LCURLY> Statement() <SEMICOL>) Block() // to disambiguate the set literals
...
}
{code}
Hope this helps...
> Block syntax is broken
> ----------------------
>
> Key: JEXL-303
> URL: https://issues.apache.org/jira/browse/JEXL-303
> Project: Commons JEXL
> Issue Type: Bug
> Affects Versions: 3.1
> Reporter: Dmitri Blinov
> Priority: Major
>
> The following script fails to parse correctly
> {code}
> {if (0) 1 else 2; var x = 1;}
> {code}
> while the following script parses perfectly
> {code}
> {var x = 1; if (0) 1 else 2;}
> {code}
> Tested with
> {code}
> @Test
> public void testOuterBlock() throws Exception {
> JexlScript e = JEXL.createScript("{if (0) 1 else 2; var x = 1;}");
> JexlContext jc = new MapContext();
> Object o = e.execute(jc);
> Assert.assertEquals("Block result is wrong", 1, o);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)