Skip to content

Commit

Permalink
[Issue-78] EL expressions that contain unnecessary parentheses fail
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiyargi committed Dec 13, 2018
1 parent 21ff915 commit 07970f9
Show file tree
Hide file tree
Showing 8 changed files with 5,519 additions and 6,133 deletions.
6,764 changes: 3,085 additions & 3,679 deletions impl/src/main/java/com/sun/el/parser/ELParser.java

Large diffs are not rendered by default.

25 changes: 21 additions & 4 deletions impl/src/main/java/com/sun/el/parser/ELParser.jjt
Expand Up @@ -21,6 +21,21 @@
Author: Kin-man Chung (EL 2.2 and EL 3.0)
*/

/* Changes from https://github.com/eclipse-ee4j/el-ri/issues/78 are
* taken from https://svn.apache.org/viewvc?view=revision&revision=1571242 and are
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* == Option Declaration == */
options
{
Expand Down Expand Up @@ -110,11 +125,12 @@ void SemiColon() : {}
/*
* Assignment
* For '=', right associatve, then LambdaExpression or Choice or Assignment
* line 132 modified with fix from https://svn.apache.org/viewvc?view=revision&revision=1571242
*/
void Assignment() : {}
{
LOOKAHEAD(3) LambdaExpression() |
Choice() (<ASSIGN> Assignment() #Assign(2) )?
LOOKAHEAD(4) LambdaExpression() |
Choice() ( LOOKAHEAD(2) <ASSIGN> Assignment() #Assign(2) )*
}

/*
Expand Down Expand Up @@ -320,12 +336,13 @@ void LambdaExpressionOrCall() #LambdaExpression : {}
/*
* NonLiteral
* For Grouped Operations, Identifiers, and Functions
* line 339,345 modified with fix from https://svn.apache.org/viewvc?view=revision&revision=1571242
*/
void NonLiteral() : {}
{
LOOKAHEAD(4) LambdaExpressionOrCall()
LOOKAHEAD(5) LambdaExpressionOrCall()
| <LPAREN> Expression() <RPAREN>
| LOOKAHEAD(4) Function()
| LOOKAHEAD((<IDENTIFIER> <COLON>)? <IDENTIFIER> <LPAREN>) Function()
| Identifier()
| MapData()
| ListData()
Expand Down
323 changes: 192 additions & 131 deletions impl/src/main/java/com/sun/el/parser/ELParserConstants.java
Expand Up @@ -13,145 +13,206 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/* Generated By:JJTree&JavaCC: Do not edit this line. ELParserConstants.java */
package com.sun.el.parser;


/**
* Token literal values and constants. Generated by org.javacc.parser.OtherFilesGen#start()
* Token literal values and constants.
* Generated by org.javacc.parser.OtherFilesGen#start()
*/
public interface ELParserConstants {

/** End of File. */
int EOF = 0;
/** RegularExpression Id. */
int LITERAL_EXPRESSION = 1;
/** RegularExpression Id. */
int START_DYNAMIC_EXPRESSION = 2;
/** RegularExpression Id. */
int START_DEFERRED_EXPRESSION = 3;
/** RegularExpression Id. */
int START_MAP = 9;
/** RegularExpression Id. */
int RCURL = 10;
/** RegularExpression Id. */
int INTEGER_LITERAL = 11;
/** RegularExpression Id. */
int FLOATING_POINT_LITERAL = 12;
/** RegularExpression Id. */
int EXPONENT = 13;
/** RegularExpression Id. */
int STRING_LITERAL = 14;
/** RegularExpression Id. */
int BADLY_ESCAPED_STRING_LITERAL = 15;
/** RegularExpression Id. */
int TRUE = 16;
/** RegularExpression Id. */
int FALSE = 17;
/** RegularExpression Id. */
int NULL = 18;
/** RegularExpression Id. */
int DOT = 19;
/** RegularExpression Id. */
int LPAREN = 20;
/** RegularExpression Id. */
int RPAREN = 21;
/** RegularExpression Id. */
int LBRACK = 22;
/** RegularExpression Id. */
int RBRACK = 23;
/** RegularExpression Id. */
int COLON = 24;
/** RegularExpression Id. */
int COMMA = 25;
/** RegularExpression Id. */
int SEMICOLON = 26;
/** RegularExpression Id. */
int GT0 = 27;
/** RegularExpression Id. */
int GT1 = 28;
/** RegularExpression Id. */
int LT0 = 29;
/** RegularExpression Id. */
int LT1 = 30;
/** RegularExpression Id. */
int GE0 = 31;
/** RegularExpression Id. */
int GE1 = 32;
/** RegularExpression Id. */
int LE0 = 33;
/** RegularExpression Id. */
int LE1 = 34;
/** RegularExpression Id. */
int EQ0 = 35;
/** RegularExpression Id. */
int EQ1 = 36;
/** RegularExpression Id. */
int NE0 = 37;
/** RegularExpression Id. */
int NE1 = 38;
/** RegularExpression Id. */
int NOT0 = 39;
/** RegularExpression Id. */
int NOT1 = 40;
/** RegularExpression Id. */
int AND0 = 41;
/** RegularExpression Id. */
int AND1 = 42;
/** RegularExpression Id. */
int OR0 = 43;
/** RegularExpression Id. */
int OR1 = 44;
/** RegularExpression Id. */
int EMPTY = 45;
/** RegularExpression Id. */
int INSTANCEOF = 46;
/** RegularExpression Id. */
int MULT = 47;
/** RegularExpression Id. */
int PLUS = 48;
/** RegularExpression Id. */
int MINUS = 49;
/** RegularExpression Id. */
int QUESTIONMARK = 50;
/** RegularExpression Id. */
int DIV0 = 51;
/** RegularExpression Id. */
int DIV1 = 52;
/** RegularExpression Id. */
int MOD0 = 53;
/** RegularExpression Id. */
int MOD1 = 54;
/** RegularExpression Id. */
int CONCAT = 55;
/** RegularExpression Id. */
int ASSIGN = 56;
/** RegularExpression Id. */
int ARROW = 57;
/** RegularExpression Id. */
int IDENTIFIER = 58;
/** RegularExpression Id. */
int IMPL_OBJ_START = 59;
/** RegularExpression Id. */
int LETTER = 60;
/** RegularExpression Id. */
int DIGIT = 61;
/** RegularExpression Id. */
int ILLEGAL_CHARACTER = 62;
/** End of File. */
int EOF = 0;
/** RegularExpression Id. */
int LITERAL_EXPRESSION = 1;
/** RegularExpression Id. */
int START_DYNAMIC_EXPRESSION = 2;
/** RegularExpression Id. */
int START_DEFERRED_EXPRESSION = 3;
/** RegularExpression Id. */
int START_MAP = 9;
/** RegularExpression Id. */
int RCURL = 10;
/** RegularExpression Id. */
int INTEGER_LITERAL = 11;
/** RegularExpression Id. */
int FLOATING_POINT_LITERAL = 12;
/** RegularExpression Id. */
int EXPONENT = 13;
/** RegularExpression Id. */
int STRING_LITERAL = 14;
/** RegularExpression Id. */
int BADLY_ESCAPED_STRING_LITERAL = 15;
/** RegularExpression Id. */
int TRUE = 16;
/** RegularExpression Id. */
int FALSE = 17;
/** RegularExpression Id. */
int NULL = 18;
/** RegularExpression Id. */
int DOT = 19;
/** RegularExpression Id. */
int LPAREN = 20;
/** RegularExpression Id. */
int RPAREN = 21;
/** RegularExpression Id. */
int LBRACK = 22;
/** RegularExpression Id. */
int RBRACK = 23;
/** RegularExpression Id. */
int COLON = 24;
/** RegularExpression Id. */
int COMMA = 25;
/** RegularExpression Id. */
int SEMICOLON = 26;
/** RegularExpression Id. */
int GT0 = 27;
/** RegularExpression Id. */
int GT1 = 28;
/** RegularExpression Id. */
int LT0 = 29;
/** RegularExpression Id. */
int LT1 = 30;
/** RegularExpression Id. */
int GE0 = 31;
/** RegularExpression Id. */
int GE1 = 32;
/** RegularExpression Id. */
int LE0 = 33;
/** RegularExpression Id. */
int LE1 = 34;
/** RegularExpression Id. */
int EQ0 = 35;
/** RegularExpression Id. */
int EQ1 = 36;
/** RegularExpression Id. */
int NE0 = 37;
/** RegularExpression Id. */
int NE1 = 38;
/** RegularExpression Id. */
int NOT0 = 39;
/** RegularExpression Id. */
int NOT1 = 40;
/** RegularExpression Id. */
int AND0 = 41;
/** RegularExpression Id. */
int AND1 = 42;
/** RegularExpression Id. */
int OR0 = 43;
/** RegularExpression Id. */
int OR1 = 44;
/** RegularExpression Id. */
int EMPTY = 45;
/** RegularExpression Id. */
int INSTANCEOF = 46;
/** RegularExpression Id. */
int MULT = 47;
/** RegularExpression Id. */
int PLUS = 48;
/** RegularExpression Id. */
int MINUS = 49;
/** RegularExpression Id. */
int QUESTIONMARK = 50;
/** RegularExpression Id. */
int DIV0 = 51;
/** RegularExpression Id. */
int DIV1 = 52;
/** RegularExpression Id. */
int MOD0 = 53;
/** RegularExpression Id. */
int MOD1 = 54;
/** RegularExpression Id. */
int CONCAT = 55;
/** RegularExpression Id. */
int ASSIGN = 56;
/** RegularExpression Id. */
int ARROW = 57;
/** RegularExpression Id. */
int IDENTIFIER = 58;
/** RegularExpression Id. */
int IMPL_OBJ_START = 59;
/** RegularExpression Id. */
int LETTER = 60;
/** RegularExpression Id. */
int DIGIT = 61;
/** RegularExpression Id. */
int ILLEGAL_CHARACTER = 62;

/** Lexical state. */
int DEFAULT = 0;
/** Lexical state. */
int IN_EXPRESSION = 1;
/** Lexical state. */
int IN_MAP = 2;
/** Lexical state. */
int DEFAULT = 0;
/** Lexical state. */
int IN_EXPRESSION = 1;
/** Lexical state. */
int IN_MAP = 2;

/** Literal token values. */
String[] tokenImage = { "<EOF>", "<LITERAL_EXPRESSION>", "\"${\"", "\"#{\"", "\"\\\\\"", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", "\"{\"", "\"}\"",
"<INTEGER_LITERAL>", "<FLOATING_POINT_LITERAL>", "<EXPONENT>", "<STRING_LITERAL>", "<BADLY_ESCAPED_STRING_LITERAL>", "\"true\"", "\"false\"",
"\"null\"", "\".\"", "\"(\"", "\")\"", "\"[\"", "\"]\"", "\":\"", "\",\"", "\";\"", "\">\"", "\"gt\"", "\"<\"", "\"lt\"", "\">=\"", "\"ge\"",
"\"<=\"", "\"le\"", "\"==\"", "\"eq\"", "\"!=\"", "\"ne\"", "\"!\"", "\"not\"", "\"&&\"", "\"and\"", "\"||\"", "\"or\"", "\"empty\"",
"\"instanceof\"", "\"*\"", "\"+\"", "\"-\"", "\"?\"", "\"/\"", "\"div\"", "\"%\"", "\"mod\"", "\"+=\"", "\"=\"", "\"->\"", "<IDENTIFIER>", "\"#\"",
"<LETTER>", "<DIGIT>", "<ILLEGAL_CHARACTER>", };
/** Literal token values. */
String[] tokenImage = {
"<EOF>",
"<LITERAL_EXPRESSION>",
"\"${\"",
"\"#{\"",
"\"\\\\\"",
"\" \"",
"\"\\t\"",
"\"\\n\"",
"\"\\r\"",
"\"{\"",
"\"}\"",
"<INTEGER_LITERAL>",
"<FLOATING_POINT_LITERAL>",
"<EXPONENT>",
"<STRING_LITERAL>",
"<BADLY_ESCAPED_STRING_LITERAL>",
"\"true\"",
"\"false\"",
"\"null\"",
"\".\"",
"\"(\"",
"\")\"",
"\"[\"",
"\"]\"",
"\":\"",
"\",\"",
"\";\"",
"\">\"",
"\"gt\"",
"\"<\"",
"\"lt\"",
"\">=\"",
"\"ge\"",
"\"<=\"",
"\"le\"",
"\"==\"",
"\"eq\"",
"\"!=\"",
"\"ne\"",
"\"!\"",
"\"not\"",
"\"&&\"",
"\"and\"",
"\"||\"",
"\"or\"",
"\"empty\"",
"\"instanceof\"",
"\"*\"",
"\"+\"",
"\"-\"",
"\"?\"",
"\"/\"",
"\"div\"",
"\"%\"",
"\"mod\"",
"\"+=\"",
"\"=\"",
"\"->\"",
"<IDENTIFIER>",
"\"#\"",
"<LETTER>",
"<DIGIT>",
"<ILLEGAL_CHARACTER>",
};

}

0 comments on commit 07970f9

Please sign in to comment.