Simplify lambda parsing

- Handle less scenarios
 - Have scenarios be defined more broadly (ie: allow more than 3 params)
 - This improves parsing performance by roughly ~10%
This commit is contained in:
Juan Martín Sotuyo Dodero
2016-10-13 14:14:34 -03:00
parent b773da1441
commit a046b8f93d

View File

@ -1,4 +1,8 @@
/**
* Improve lambda detection in PrimaryPrefix to improve parsing performance.
*
* Juan Martin Sotuyo Dodero 10/2016
*====================================================================
* Fix for an expression within an additive expression that was
* wrongly taken as a cast expression.
* Bug #1484
@ -1809,12 +1813,9 @@ void PrimaryPrefix() :
| LOOKAHEAD(2) "this" {jjtThis.setUsesThisModifier();}
| "super" {jjtThis.setUsesSuperModifier();}
| LOOKAHEAD( "(" ")" "->" ) LambdaExpression()
| LOOKAHEAD( <IDENTIFIER> "->" ) LambdaExpression()
| LOOKAHEAD( "(" VariableDeclaratorId() ")" "->" ) LambdaExpression()
| LOOKAHEAD( "(" VariableDeclaratorId() "," VariableDeclaratorId() ["," VariableDeclaratorId()] ")" "->" ) LambdaExpression()
| LOOKAHEAD( "(" FormalParameter() ")" "->" ) LambdaExpression()
| LOOKAHEAD( "(" FormalParameter() "," FormalParameter() ["," FormalParameter() ] ")" "->" ) LambdaExpression()
| LOOKAHEAD( LambdaExpression() ) LambdaExpression()
| LOOKAHEAD( VariableDeclaratorId() "->" ) LambdaExpression()
| LOOKAHEAD( "(" VariableDeclaratorId() ( "," VariableDeclaratorId() )* ")" "->" ) LambdaExpression()
| LOOKAHEAD( FormalParameters() "->" ) LambdaExpression()
| LOOKAHEAD(3) "(" Expression() ")"
| AllocationExpression()
| LOOKAHEAD( ResultType() "." "class" ) ResultType() "." "class"