From a042a3ca33d551a8882544ca7f3ee658f8438124 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Mon, 27 Nov 2006 04:21:37 +0000 Subject: [PATCH] The CastLookahead production can be #void, too git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4832 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/grammar/Java.jjt | 2 +- .../sourceforge/pmd/ast/ASTCastLookahead.java | 21 ---- .../net/sourceforge/pmd/ast/JavaParser.java | 116 +++++++----------- .../pmd/ast/JavaParserTreeConstants.java | 106 ++++++++-------- .../pmd/ast/JavaParserVisitor.java | 1 - .../pmd/ast/JavaParserVisitorAdapter.java | 4 - 6 files changed, 99 insertions(+), 151 deletions(-) delete mode 100644 pmd/src/net/sourceforge/pmd/ast/ASTCastLookahead.java diff --git a/pmd/etc/grammar/Java.jjt b/pmd/etc/grammar/Java.jjt index cb49e24182..3362ba6bc3 100644 --- a/pmd/etc/grammar/Java.jjt +++ b/pmd/etc/grammar/Java.jjt @@ -1605,7 +1605,7 @@ void UnaryExpressionNotPlusMinus() #UnaryExpressionNotPlusMinus((jjtn000.getImag // This production is to determine lookahead only. The LOOKAHEAD specifications // below are not used, but they are there just to indicate that we know about // this. -void CastLookahead() : +void CastLookahead() #void : {} { LOOKAHEAD(2) "(" PrimitiveType() | LOOKAHEAD("(" Type() "[") "(" Type() "[" "]" diff --git a/pmd/src/net/sourceforge/pmd/ast/ASTCastLookahead.java b/pmd/src/net/sourceforge/pmd/ast/ASTCastLookahead.java deleted file mode 100644 index 77e51c99f8..0000000000 --- a/pmd/src/net/sourceforge/pmd/ast/ASTCastLookahead.java +++ /dev/null @@ -1,21 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTCastLookahead.java */ - -package net.sourceforge.pmd.ast; - -public class ASTCastLookahead extends SimpleJavaNode { - public ASTCastLookahead(int id) { - super(id); - } - - public ASTCastLookahead(JavaParser p, int id) { - super(p, id); - } - - - /** - * Accept the visitor. * - */ - public Object jjtAccept(JavaParserVisitor visitor, Object data) { - return visitor.visit(this, data); - } -} diff --git a/pmd/src/net/sourceforge/pmd/ast/JavaParser.java b/pmd/src/net/sourceforge/pmd/ast/JavaParser.java index 4ad1b34fdf..25df8ae4dc 100644 --- a/pmd/src/net/sourceforge/pmd/ast/JavaParser.java +++ b/pmd/src/net/sourceforge/pmd/ast/JavaParser.java @@ -3220,87 +3220,63 @@ Token t; // below are not used, but they are there just to indicate that we know about // this. final public void CastLookahead() throws ParseException { - /*@bgen(jjtree) CastLookahead */ - ASTCastLookahead jjtn000 = new ASTCastLookahead(this, JJTCASTLOOKAHEAD); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); - try { - if (jj_2_25(2)) { - jj_consume_token(LPAREN); - PrimitiveType(); - } else if (jj_2_26(2147483647)) { + if (jj_2_25(2)) { + jj_consume_token(LPAREN); + PrimitiveType(); + } else if (jj_2_26(2147483647)) { + jj_consume_token(LPAREN); + Type(); + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + } else { + switch (jj_nt.kind) { + case LPAREN: jj_consume_token(LPAREN); Type(); - jj_consume_token(LBRACKET); - jj_consume_token(RBRACKET); - } else { + jj_consume_token(RPAREN); switch (jj_nt.kind) { + case TILDE: + jj_consume_token(TILDE); + break; + case BANG: + jj_consume_token(BANG); + break; case LPAREN: jj_consume_token(LPAREN); - Type(); - jj_consume_token(RPAREN); - switch (jj_nt.kind) { - case TILDE: - jj_consume_token(TILDE); - break; - case BANG: - jj_consume_token(BANG); - break; - case LPAREN: - jj_consume_token(LPAREN); - break; - case IDENTIFIER: - jj_consume_token(IDENTIFIER); - break; - case THIS: - jj_consume_token(THIS); - break; - case SUPER: - jj_consume_token(SUPER); - break; - case NEW: - jj_consume_token(NEW); - break; - case FALSE: - case NULL: - case TRUE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case HEX_FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - Literal(); - break; - default: - jj_la1[85] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } + break; + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case THIS: + jj_consume_token(THIS); + break; + case SUPER: + jj_consume_token(SUPER); + break; + case NEW: + jj_consume_token(NEW); + break; + case FALSE: + case NULL: + case TRUE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case HEX_FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + Literal(); break; default: - jj_la1[86] = jj_gen; + jj_la1[85] = jj_gen; jj_consume_token(-1); throw new ParseException(); } + break; + default: + jj_la1[86] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } - } catch (Throwable jjte000) { - if (jjtc000) { - jjtree.clearNodeScope(jjtn000); - jjtc000 = false; - } else { - jjtree.popNode(); - } - if (jjte000 instanceof RuntimeException) { - {if (true) throw (RuntimeException)jjte000;} - } - if (jjte000 instanceof ParseException) { - {if (true) throw (ParseException)jjte000;} - } - {if (true) throw (Error)jjte000;} - } finally { - if (jjtc000) { - jjtree.closeNodeScope(jjtn000, true); - } } } diff --git a/pmd/src/net/sourceforge/pmd/ast/JavaParserTreeConstants.java b/pmd/src/net/sourceforge/pmd/ast/JavaParserTreeConstants.java index 430a6da28e..d33291ac78 100644 --- a/pmd/src/net/sourceforge/pmd/ast/JavaParserTreeConstants.java +++ b/pmd/src/net/sourceforge/pmd/ast/JavaParserTreeConstants.java @@ -60,59 +60,58 @@ public interface JavaParserTreeConstants public int JJTPREINCREMENTEXPRESSION = 53; public int JJTPREDECREMENTEXPRESSION = 54; public int JJTUNARYEXPRESSIONNOTPLUSMINUS = 55; - public int JJTCASTLOOKAHEAD = 56; - public int JJTPOSTFIXEXPRESSION = 57; - public int JJTCASTEXPRESSION = 58; - public int JJTPRIMARYEXPRESSION = 59; - public int JJTMEMBERSELECTOR = 60; - public int JJTPRIMARYPREFIX = 61; - public int JJTPRIMARYSUFFIX = 62; - public int JJTLITERAL = 63; - public int JJTBOOLEANLITERAL = 64; - public int JJTNULLLITERAL = 65; - public int JJTARGUMENTS = 66; - public int JJTARGUMENTLIST = 67; - public int JJTALLOCATIONEXPRESSION = 68; - public int JJTARRAYDIMSANDINITS = 69; - public int JJTSTATEMENT = 70; - public int JJTLABELEDSTATEMENT = 71; - public int JJTBLOCK = 72; - public int JJTBLOCKSTATEMENT = 73; - public int JJTLOCALVARIABLEDECLARATION = 74; - public int JJTEMPTYSTATEMENT = 75; - public int JJTSTATEMENTEXPRESSION = 76; - public int JJTSWITCHSTATEMENT = 77; - public int JJTSWITCHLABEL = 78; - public int JJTIFSTATEMENT = 79; - public int JJTWHILESTATEMENT = 80; - public int JJTDOSTATEMENT = 81; - public int JJTFORSTATEMENT = 82; - public int JJTFORINIT = 83; - public int JJTSTATEMENTEXPRESSIONLIST = 84; - public int JJTFORUPDATE = 85; - public int JJTBREAKSTATEMENT = 86; - public int JJTCONTINUESTATEMENT = 87; - public int JJTRETURNSTATEMENT = 88; - public int JJTTHROWSTATEMENT = 89; - public int JJTSYNCHRONIZEDSTATEMENT = 90; - public int JJTTRYSTATEMENT = 91; - public int JJTCATCHSTATEMENT = 92; - public int JJTFINALLYSTATEMENT = 93; - public int JJTASSERTSTATEMENT = 94; - public int JJTRUNSIGNEDSHIFT = 95; - public int JJTRSIGNEDSHIFT = 96; - public int JJTANNOTATION = 97; - public int JJTNORMALANNOTATION = 98; - public int JJTMARKERANNOTATION = 99; - public int JJTSINGLEMEMBERANNOTATION = 100; - public int JJTMEMBERVALUEPAIRS = 101; - public int JJTMEMBERVALUEPAIR = 102; - public int JJTMEMBERVALUE = 103; - public int JJTMEMBERVALUEARRAYINITIALIZER = 104; - public int JJTANNOTATIONTYPEDECLARATION = 105; - public int JJTANNOTATIONTYPEBODY = 106; - public int JJTANNOTATIONTYPEMEMBERDECLARATION = 107; - public int JJTDEFAULTVALUE = 108; + public int JJTPOSTFIXEXPRESSION = 56; + public int JJTCASTEXPRESSION = 57; + public int JJTPRIMARYEXPRESSION = 58; + public int JJTMEMBERSELECTOR = 59; + public int JJTPRIMARYPREFIX = 60; + public int JJTPRIMARYSUFFIX = 61; + public int JJTLITERAL = 62; + public int JJTBOOLEANLITERAL = 63; + public int JJTNULLLITERAL = 64; + public int JJTARGUMENTS = 65; + public int JJTARGUMENTLIST = 66; + public int JJTALLOCATIONEXPRESSION = 67; + public int JJTARRAYDIMSANDINITS = 68; + public int JJTSTATEMENT = 69; + public int JJTLABELEDSTATEMENT = 70; + public int JJTBLOCK = 71; + public int JJTBLOCKSTATEMENT = 72; + public int JJTLOCALVARIABLEDECLARATION = 73; + public int JJTEMPTYSTATEMENT = 74; + public int JJTSTATEMENTEXPRESSION = 75; + public int JJTSWITCHSTATEMENT = 76; + public int JJTSWITCHLABEL = 77; + public int JJTIFSTATEMENT = 78; + public int JJTWHILESTATEMENT = 79; + public int JJTDOSTATEMENT = 80; + public int JJTFORSTATEMENT = 81; + public int JJTFORINIT = 82; + public int JJTSTATEMENTEXPRESSIONLIST = 83; + public int JJTFORUPDATE = 84; + public int JJTBREAKSTATEMENT = 85; + public int JJTCONTINUESTATEMENT = 86; + public int JJTRETURNSTATEMENT = 87; + public int JJTTHROWSTATEMENT = 88; + public int JJTSYNCHRONIZEDSTATEMENT = 89; + public int JJTTRYSTATEMENT = 90; + public int JJTCATCHSTATEMENT = 91; + public int JJTFINALLYSTATEMENT = 92; + public int JJTASSERTSTATEMENT = 93; + public int JJTRUNSIGNEDSHIFT = 94; + public int JJTRSIGNEDSHIFT = 95; + public int JJTANNOTATION = 96; + public int JJTNORMALANNOTATION = 97; + public int JJTMARKERANNOTATION = 98; + public int JJTSINGLEMEMBERANNOTATION = 99; + public int JJTMEMBERVALUEPAIRS = 100; + public int JJTMEMBERVALUEPAIR = 101; + public int JJTMEMBERVALUE = 102; + public int JJTMEMBERVALUEARRAYINITIALIZER = 103; + public int JJTANNOTATIONTYPEDECLARATION = 104; + public int JJTANNOTATIONTYPEBODY = 105; + public int JJTANNOTATIONTYPEMEMBERDECLARATION = 106; + public int JJTDEFAULTVALUE = 107; public String[] jjtNodeName = { @@ -172,7 +171,6 @@ public interface JavaParserTreeConstants "PreIncrementExpression", "PreDecrementExpression", "UnaryExpressionNotPlusMinus", - "CastLookahead", "PostfixExpression", "CastExpression", "PrimaryExpression", diff --git a/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitor.java b/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitor.java index 6a4fee8ce7..993132fc2b 100644 --- a/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitor.java +++ b/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitor.java @@ -60,7 +60,6 @@ public interface JavaParserVisitor public Object visit(ASTPreIncrementExpression node, Object data); public Object visit(ASTPreDecrementExpression node, Object data); public Object visit(ASTUnaryExpressionNotPlusMinus node, Object data); - public Object visit(ASTCastLookahead node, Object data); public Object visit(ASTPostfixExpression node, Object data); public Object visit(ASTCastExpression node, Object data); public Object visit(ASTPrimaryExpression node, Object data); diff --git a/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitorAdapter.java b/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitorAdapter.java index c05457647e..924d208725 100644 --- a/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitorAdapter.java +++ b/pmd/src/net/sourceforge/pmd/ast/JavaParserVisitorAdapter.java @@ -295,10 +295,6 @@ public class JavaParserVisitorAdapter implements JavaParserVisitor { return visit((SimpleJavaNode) node, data); } - public Object visit(ASTCastLookahead node, Object data) { - return visit((SimpleJavaNode) node, data); - } - public Object visit(ASTPostfixExpression node, Object data) { return visit((SimpleJavaNode) node, data); }