diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 24b576ddd2..9dc7824677 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1,4 +1,8 @@ /** + * Improve lambda detection in PrimaryPrefix to improve parsing performance. + * + * Juan Martin Sotuyo Dodero 10/2016 + *==================================================================== * Fix for regression introduced in previous changeset. * The syntactic lookahead was not properly handled by javacc, * so it was converted to a semantic one @@ -1815,13 +1819,9 @@ void PrimaryPrefix() : Literal() | LOOKAHEAD(2) "this" {jjtThis.setUsesThisModifier();} | "super" {jjtThis.setUsesSuperModifier();} -| LOOKAHEAD( "(" ")" "->" ) LambdaExpression() | LOOKAHEAD( "->" ) LambdaExpression() -| LOOKAHEAD( "(" VariableDeclaratorId() ")" "->" ) LambdaExpression() -| LOOKAHEAD( "(" VariableDeclaratorId() "," VariableDeclaratorId() ["," VariableDeclaratorId()] ")" "->" ) LambdaExpression() -| LOOKAHEAD( "(" FormalParameter() ")" "->" ) LambdaExpression() -| LOOKAHEAD( "(" FormalParameter() "," FormalParameter() ["," FormalParameter() ] ")" "->" ) LambdaExpression() -| LOOKAHEAD( LambdaExpression() ) LambdaExpression() +| LOOKAHEAD( "(" VariableDeclaratorId() ( "," VariableDeclaratorId() )* ")" "->" ) LambdaExpression() +| LOOKAHEAD( FormalParameters() "->" ) LambdaExpression() | LOOKAHEAD(3) "(" Expression() ")" | AllocationExpression() | LOOKAHEAD( ResultType() "." "class" ) ResultType() "." "class"