forked from phoedos/pmd
fixed 1.5 parsing bugs: hex floating points, annotations before enum constants
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4740 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -110,6 +110,12 @@ public class JavaParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForBadHexFloatingPointLiteral() {
|
||||
if (!isJDK15) {
|
||||
throw new ParseException("ERROR: Can't use hexadecimal floating point literals in pre-JDK 1.5 target");
|
||||
}
|
||||
}
|
||||
|
||||
// This is a semantic LOOKAHEAD to determine if we're dealing with an assert
|
||||
// Note that this can't be replaced with a syntactic lookahead
|
||||
// since "assert" isn't a string literal token
|
||||
@ -279,6 +285,10 @@ TOKEN :
|
||||
| (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
|
||||
| (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
|
||||
>
|
||||
|
|
||||
< HEX_FLOATING_POINT_LITERAL:
|
||||
(<HEX_LITERAL> (".")? | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+) ["p","P"] (["+","-"])? (["0"-"9"])+ (["f","F","d","D"])?
|
||||
>
|
||||
|
|
||||
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
|
||||
|
|
||||
@ -1177,7 +1187,7 @@ void EnumBody():
|
||||
{}
|
||||
{
|
||||
"{"
|
||||
[ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
|
||||
[( Annotation() )* EnumConstant() ( LOOKAHEAD(2) "," ( Annotation() )* EnumConstant() )* ]
|
||||
[ "," ]
|
||||
[ ";" ( ClassOrInterfaceBodyDeclaration() )* ]
|
||||
"}"
|
||||
@ -1651,6 +1661,7 @@ void Literal() :
|
||||
{ Token t;}
|
||||
t=<INTEGER_LITERAL> {jjtThis.setImage(t.image);}
|
||||
| t=<FLOATING_POINT_LITERAL> {jjtThis.setImage(t.image);}
|
||||
| t=<HEX_FLOATING_POINT_LITERAL> { checkForBadHexFloatingPointLiteral(); jjtThis.setImage(t.image);}
|
||||
| t=<CHARACTER_LITERAL> {jjtThis.setImage(t.image);}
|
||||
| t=<STRING_LITERAL> {jjtThis.setImage(t.image);}
|
||||
| BooleanLiteral()
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -63,60 +63,61 @@ public interface JavaParserConstants {
|
||||
int HEX_LITERAL = 65;
|
||||
int OCTAL_LITERAL = 66;
|
||||
int FLOATING_POINT_LITERAL = 67;
|
||||
int EXPONENT = 68;
|
||||
int CHARACTER_LITERAL = 69;
|
||||
int STRING_LITERAL = 70;
|
||||
int IDENTIFIER = 71;
|
||||
int LETTER = 72;
|
||||
int PART_LETTER = 73;
|
||||
int LPAREN = 74;
|
||||
int RPAREN = 75;
|
||||
int LBRACE = 76;
|
||||
int RBRACE = 77;
|
||||
int LBRACKET = 78;
|
||||
int RBRACKET = 79;
|
||||
int SEMICOLON = 80;
|
||||
int COMMA = 81;
|
||||
int DOT = 82;
|
||||
int AT = 83;
|
||||
int ASSIGN = 84;
|
||||
int LT = 85;
|
||||
int BANG = 86;
|
||||
int TILDE = 87;
|
||||
int HOOK = 88;
|
||||
int COLON = 89;
|
||||
int EQ = 90;
|
||||
int LE = 91;
|
||||
int GE = 92;
|
||||
int NE = 93;
|
||||
int SC_OR = 94;
|
||||
int SC_AND = 95;
|
||||
int INCR = 96;
|
||||
int DECR = 97;
|
||||
int PLUS = 98;
|
||||
int MINUS = 99;
|
||||
int STAR = 100;
|
||||
int SLASH = 101;
|
||||
int BIT_AND = 102;
|
||||
int BIT_OR = 103;
|
||||
int XOR = 104;
|
||||
int REM = 105;
|
||||
int LSHIFT = 106;
|
||||
int PLUSASSIGN = 107;
|
||||
int MINUSASSIGN = 108;
|
||||
int STARASSIGN = 109;
|
||||
int SLASHASSIGN = 110;
|
||||
int ANDASSIGN = 111;
|
||||
int ORASSIGN = 112;
|
||||
int XORASSIGN = 113;
|
||||
int REMASSIGN = 114;
|
||||
int LSHIFTASSIGN = 115;
|
||||
int RSIGNEDSHIFTASSIGN = 116;
|
||||
int RUNSIGNEDSHIFTASSIGN = 117;
|
||||
int ELLIPSIS = 118;
|
||||
int RUNSIGNEDSHIFT = 119;
|
||||
int RSIGNEDSHIFT = 120;
|
||||
int GT = 121;
|
||||
int HEX_FLOATING_POINT_LITERAL = 68;
|
||||
int EXPONENT = 69;
|
||||
int CHARACTER_LITERAL = 70;
|
||||
int STRING_LITERAL = 71;
|
||||
int IDENTIFIER = 72;
|
||||
int LETTER = 73;
|
||||
int PART_LETTER = 74;
|
||||
int LPAREN = 75;
|
||||
int RPAREN = 76;
|
||||
int LBRACE = 77;
|
||||
int RBRACE = 78;
|
||||
int LBRACKET = 79;
|
||||
int RBRACKET = 80;
|
||||
int SEMICOLON = 81;
|
||||
int COMMA = 82;
|
||||
int DOT = 83;
|
||||
int AT = 84;
|
||||
int ASSIGN = 85;
|
||||
int LT = 86;
|
||||
int BANG = 87;
|
||||
int TILDE = 88;
|
||||
int HOOK = 89;
|
||||
int COLON = 90;
|
||||
int EQ = 91;
|
||||
int LE = 92;
|
||||
int GE = 93;
|
||||
int NE = 94;
|
||||
int SC_OR = 95;
|
||||
int SC_AND = 96;
|
||||
int INCR = 97;
|
||||
int DECR = 98;
|
||||
int PLUS = 99;
|
||||
int MINUS = 100;
|
||||
int STAR = 101;
|
||||
int SLASH = 102;
|
||||
int BIT_AND = 103;
|
||||
int BIT_OR = 104;
|
||||
int XOR = 105;
|
||||
int REM = 106;
|
||||
int LSHIFT = 107;
|
||||
int PLUSASSIGN = 108;
|
||||
int MINUSASSIGN = 109;
|
||||
int STARASSIGN = 110;
|
||||
int SLASHASSIGN = 111;
|
||||
int ANDASSIGN = 112;
|
||||
int ORASSIGN = 113;
|
||||
int XORASSIGN = 114;
|
||||
int REMASSIGN = 115;
|
||||
int LSHIFTASSIGN = 116;
|
||||
int RSIGNEDSHIFTASSIGN = 117;
|
||||
int RUNSIGNEDSHIFTASSIGN = 118;
|
||||
int ELLIPSIS = 119;
|
||||
int RUNSIGNEDSHIFT = 120;
|
||||
int RSIGNEDSHIFT = 121;
|
||||
int GT = 122;
|
||||
|
||||
int DEFAULT = 0;
|
||||
int IN_FORMAL_COMMENT = 1;
|
||||
@ -191,6 +192,7 @@ public interface JavaParserConstants {
|
||||
"<HEX_LITERAL>",
|
||||
"<OCTAL_LITERAL>",
|
||||
"<FLOATING_POINT_LITERAL>",
|
||||
"<HEX_FLOATING_POINT_LITERAL>",
|
||||
"<EXPONENT>",
|
||||
"<CHARACTER_LITERAL>",
|
||||
"<STRING_LITERAL>",
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user