Skip to content

Commit

Permalink
Investigate if ECJ's parser be simplified by incorporating overlooked
Browse files Browse the repository at this point in the history
last minute spec revisions eclipse-jdt#1045

WIP regargding
eclipse-jdt#1045
  • Loading branch information
stephan-herrmann committed Sep 26, 2024
1 parent cb2ef5d commit e07087d
Show file tree
Hide file tree
Showing 29 changed files with 370 additions and 348 deletions.
14 changes: 13 additions & 1 deletion org.eclipse.jdt.core.compiler.batch/grammar/java.g
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,6 @@ PrimaryNoNewArray -> ArrayAccess
-- Start of rules for JSR 335
-----------------------------------------------------------------------

PrimaryNoNewArray -> LambdaExpression
PrimaryNoNewArray -> ReferenceExpression
/:$readableName Expression:/

Expand Down Expand Up @@ -2156,6 +2155,9 @@ CastExpression ::= BeginIntersectionCast PushLPAREN CastNameAndBounds PushRPARE
CastExpression ::= PushLPAREN Name Dims AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
/.$putCase consumeCastExpressionWithNameArray(); $break ./
/:$readableName CastExpression:/
CastExpression ::= PushLPAREN Name PushRPAREN InsideCastExpressionLL1 LambdaExpression
/.$putCase consumeCastExpressionLL1(); $break ./
/:$readableName CastExpression:/

AdditionalBoundsListOpt ::= $empty
/.$putCase consumeZeroAdditionalBounds(); $break ./
Expand Down Expand Up @@ -2261,6 +2263,9 @@ ConditionalExpression -> ConditionalOrExpression
ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
/.$putCase consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ; $break ./
/:$readableName Expression:/
ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' LambdaExpression
/.$putCase consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ; $break ./
/:$readableName Expression:/

AssignmentExpression -> ConditionalExpression
AssignmentExpression -> Assignment
Expand Down Expand Up @@ -2313,6 +2318,10 @@ Expression ::= AssignmentExpression
/:$readableName Expression:/
/:$recovery_template Identifier:/

Expression ::= LambdaExpression
/.$putCase consumeExpression(); $break ./
/:$readableName Expression:/

-- The following rules are for optional nonterminals.
--
ClassHeaderExtendsopt ::= $empty
Expand Down Expand Up @@ -2916,6 +2925,9 @@ AssignmentExpression_NotName -> Assignment

Expression_NotName -> AssignmentExpression_NotName
/:$readableName Expression:/
Expression_NotName -> LambdaExpression
/:$readableName Expression:/

-----------------------------------------------
-- 1.5 features : end of generics
-----------------------------------------------
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ public interface ParserBasicInformation {
public final static int
// BEGIN_AUTOGENERATED_REGION

ERROR_SYMBOL = 138,
MAX_NAME_LENGTH = 41,
NUM_STATES = 1243,
ERROR_SYMBOL = 138,
MAX_NAME_LENGTH = 41,
NUM_STATES = 1224,

NT_OFFSET = 138,
SCOPE_UBOUND = 320,
SCOPE_SIZE = 321,
LA_STATE_OFFSET = 18269,
MAX_LA = 1,
NUM_RULES = 948,
NUM_TERMINALS = 138,
NUM_NON_TERMINALS = 437,
NUM_SYMBOLS = 575,
START_STATE = 1143,
EOFT_SYMBOL = 39,
EOLT_SYMBOL = 39,
ACCEPT_ACTION = 18268,
ERROR_ACTION = 18269;
NT_OFFSET = 138,
SCOPE_UBOUND = 322,
SCOPE_SIZE = 323,
LA_STATE_OFFSET = 18469,
MAX_LA = 1,
NUM_RULES = 951,
NUM_TERMINALS = 138,
NUM_NON_TERMINALS = 437,
NUM_SYMBOLS = 575,
START_STATE = 1145,
EOFT_SYMBOL = 42,
EOLT_SYMBOL = 42,
ACCEPT_ACTION = 18468,
ERROR_ACTION = 18469;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5726,7 +5726,8 @@ int disambiguatedToken(int token, Scanner scanner) {
// TODO: Inefficient method due to redoing of the same source, investigate alternate
// Can we do a dup of parsing/check the transition of the state?
return disambiguateArrowWithCaseExpr(scanner, token);
} else if (token == TokenNameLPAREN && maybeAtLambdaOrCast()) {
} else if (token == TokenNameLPAREN // && maybeAtLambdaOrCast()
) {
if (parser.parse(Goal.LambdaParameterListGoal) == VanguardParser.SUCCESS) {
scanner.nextToken = TokenNameLPAREN;
return TokenNameBeginLambda;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,62 +72,62 @@ static int getRestrictedKeyword(String text) {
}

// BEGIN_AUTOGENERATED_REGION
int TokenNameIdentifier = 19,
TokenNameabstract = 44,
int TokenNameIdentifier = 17,
TokenNameabstract = 43,
TokenNameassert = 82,
TokenNameboolean = 106,
TokenNameboolean = 105,
TokenNamebreak = 83,
TokenNamebyte = 107,
TokenNamebyte = 106,
TokenNamecase = 92,
TokenNamecatch = 108,
TokenNamechar = 109,
TokenNameclass = 71,
TokenNamecatch = 107,
TokenNamechar = 108,
TokenNameclass = 70,
TokenNamecontinue = 84,
TokenNameconst = 136,
TokenNamedefault = 77,
TokenNamedefault = 76,
TokenNamedo = 85,
TokenNamedouble = 110,
TokenNamedouble = 109,
TokenNameelse = 121,
TokenNameenum = 75,
TokenNameenum = 72,
TokenNameextends = 93,
TokenNamefalse = 54,
TokenNamefinal = 45,
TokenNamefalse = 53,
TokenNamefinal = 44,
TokenNamefinally = 118,
TokenNamefloat = 111,
TokenNamefloat = 110,
TokenNamefor = 86,
TokenNamegoto = 137,
TokenNameif = 87,
TokenNameimplements = 133,
TokenNameimport = 112,
TokenNameinstanceof = 17,
TokenNameint = 113,
TokenNameinterface = 72,
TokenNamelong = 114,
TokenNamenative = 46,
TokenNamenew = 40,
TokenNamenon_sealed = 47,
TokenNamenull = 55,
TokenNameimport = 111,
TokenNameinstanceof = 18,
TokenNameint = 112,
TokenNameinterface = 71,
TokenNamelong = 113,
TokenNamenative = 45,
TokenNamenew = 37,
TokenNamenon_sealed = 46,
TokenNamenull = 54,
TokenNamepackage = 91,
TokenNameprivate = 48,
TokenNameprotected = 49,
TokenNamepublic = 50,
TokenNameprivate = 47,
TokenNameprotected = 48,
TokenNamepublic = 49,
TokenNamereturn = 88,
TokenNameshort = 115,
TokenNameshort = 114,
TokenNamestatic = 38,
TokenNamestrictfp = 51,
TokenNamesuper = 36,
TokenNameswitch = 65,
TokenNamesynchronized = 41,
TokenNamethis = 37,
TokenNamestrictfp = 50,
TokenNamesuper = 34,
TokenNameswitch = 63,
TokenNamesynchronized = 39,
TokenNamethis = 35,
TokenNamethrow = 79,
TokenNamethrows = 119,
TokenNametransient = 52,
TokenNametrue = 56,
TokenNametransient = 51,
TokenNametrue = 55,
TokenNametry = 89,
TokenNamevoid = 116,
TokenNamevolatile = 53,
TokenNamevoid = 115,
TokenNamevolatile = 52,
TokenNamewhile = 80,
TokenNamemodule = 117,
TokenNamemodule = 116,
TokenNameopen = 122,
TokenNamerequires = 123,
TokenNametransitive = 128,
Expand All @@ -137,21 +137,21 @@ static int getRestrictedKeyword(String text) {
TokenNameuses = 126,
TokenNameprovides = 127,
TokenNamewith = 135,
TokenNameIntegerLiteral = 57,
TokenNameLongLiteral = 58,
TokenNameFloatingPointLiteral = 59,
TokenNameDoubleLiteral = 60,
TokenNameCharacterLiteral = 61,
TokenNameStringLiteral = 62,
TokenNameTextBlock = 63,
TokenNameIntegerLiteral = 56,
TokenNameLongLiteral = 57,
TokenNameFloatingPointLiteral = 58,
TokenNameDoubleLiteral = 59,
TokenNameCharacterLiteral = 60,
TokenNameStringLiteral = 61,
TokenNameTextBlock = 62,
TokenNamePLUS_PLUS = 2,
TokenNameMINUS_MINUS = 3,
TokenNameEQUAL_EQUAL = 20,
TokenNameLESS_EQUAL = 12,
TokenNameGREATER_EQUAL = 13,
TokenNameNOT_EQUAL = 21,
TokenNameLEFT_SHIFT = 18,
TokenNameRIGHT_SHIFT = 14,
TokenNameEQUAL_EQUAL = 21,
TokenNameLESS_EQUAL = 13,
TokenNameGREATER_EQUAL = 14,
TokenNameNOT_EQUAL = 22,
TokenNameLEFT_SHIFT = 19,
TokenNameRIGHT_SHIFT = 12,
TokenNameUNSIGNED_RIGHT_SHIFT = 16,
TokenNamePLUS_EQUAL = 94,
TokenNameMINUS_EQUAL = 95,
Expand All @@ -168,46 +168,46 @@ static int getRestrictedKeyword(String text) {
TokenNameAND_AND = 30,
TokenNamePLUS = 4,
TokenNameMINUS = 5,
TokenNameNOT = 67,
TokenNameREMAINDER = 9,
TokenNameXOR = 25,
TokenNameAND = 22,
TokenNameMULTIPLY = 8,
TokenNameNOT = 64,
TokenNameREMAINDER = 8,
TokenNameXOR = 27,
TokenNameAND = 23,
TokenNameMULTIPLY = 7,
TokenNameOR = 28,
TokenNameTWIDDLE = 68,
TokenNameDIVIDE = 10,
TokenNameTWIDDLE = 65,
TokenNameDIVIDE = 9,
TokenNameGREATER = 15,
TokenNameLESS = 11,
TokenNameLPAREN = 23,
TokenNameLESS = 6,
TokenNameLPAREN = 20,
TokenNameRPAREN = 26,
TokenNameLBRACE = 42,
TokenNameLBRACE = 40,
TokenNameRBRACE = 33,
TokenNameLBRACKET = 6,
TokenNameRBRACKET = 70,
TokenNameLBRACKET = 10,
TokenNameRBRACKET = 69,
TokenNameSEMICOLON = 24,
TokenNameQUESTION = 29,
TokenNameCOLON = 66,
TokenNameCOMMA = 32,
TokenNameDOT = 1,
TokenNameEQUAL = 78,
TokenNameAT = 35,
TokenNameAT = 36,
TokenNameELLIPSIS = 120,
TokenNameARROW = 105,
TokenNameCOLON_COLON = 7,
TokenNameBeginLambda = 64,
TokenNameBeginIntersectionCast = 69,
TokenNameARROW = 117,
TokenNameCOLON_COLON = 11,
TokenNameBeginLambda = 77,
TokenNameBeginIntersectionCast = 67,
TokenNameBeginTypeArguments = 90,
TokenNameElidedSemicolonAndRightBrace = 73,
TokenNameAT308 = 27,
TokenNameAT308 = 25,
TokenNameAT308DOTDOTDOT = 129,
TokenNameBeginCaseExpr = 74,
TokenNameRestrictedIdentifierYield = 81,
TokenNameRestrictedIdentifierrecord = 76,
TokenNameRestrictedIdentifiersealed = 43,
TokenNameRestrictedIdentifierrecord = 75,
TokenNameRestrictedIdentifiersealed = 41,
TokenNameRestrictedIdentifierpermits = 130,
TokenNameBeginCaseElement = 131,
TokenNameRestrictedIdentifierWhen = 132,
TokenNameUNDERSCORE = 34,
TokenNameEOF = 39,
TokenNameUNDERSCORE = 68,
TokenNameEOF = 42,
TokenNameERROR = 138;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e07087d

Please sign in to comment.