Ugly workaround that don't need to change AST

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-02-14 03:00:39 -03:00
committed by Andreas Dangel
parent 907972f0ca
commit 8f22e69560
2 changed files with 9 additions and 3 deletions

View File

@ -1788,7 +1788,13 @@ void UnaryExpressionNotPlusMinus() #UnaryExpressionNotPlusMinus((jjtn000.getImag
{}
{
( "~" {jjtThis.setImage("~");} | "!" {jjtThis.setImage("!");} ) UnaryExpression()
| LOOKAHEAD(CastExpression()) CastExpression()
/*
* This is really ugly... we are repeting the CastExpression lookahead and full expression...
* If we don't the lookahead within CastExpression is ignored, and it simply looks for the expression,
* meaning we can't be explicit as to what can be casted depending on the cast type (primitive or otherwhise)
*/
| LOOKAHEAD("(" (Annotation())* PrimitiveType() ")") CastExpression()
| LOOKAHEAD("(" (Annotation())* Type() ( "&" ReferenceType() )* ")" UnaryExpressionNotPlusMinus()) CastExpression()
| PostfixExpression()
}
@ -1803,7 +1809,7 @@ void CastExpression() :
{
LOOKAHEAD(
"(" (Annotation())* PrimitiveType() ")"
) "(" (Annotation() {checkForBadTypeAnnotations();})* PrimitiveType() ")" UnaryExpression()
) "(" (Annotation() {checkForBadTypeAnnotations();})* Type() ")" UnaryExpression()
| "(" (Annotation() {checkForBadTypeAnnotations();})* Type() ( "&" {checkForBadIntersectionTypesInCasts(); jjtThis.setIntersectionTypes(true);} ReferenceType() )* ")" UnaryExpressionNotPlusMinus()
}

View File

@ -379,7 +379,7 @@ adverse impacts on performance.
<property name="xpath">
<value>
<![CDATA[
//PrimitiveType[@Image = 'short'][name(..) != 'CastExpression']
//PrimitiveType[@Image = 'short'][name(../..) != 'CastExpression']
]]>
</value>
</property>