forked from jasder/antlr
Remove unnecessary variable initializations
This commit is contained in:
parent
6045bd4eb5
commit
44ef41ff29
|
@ -112,7 +112,7 @@ public class ParserATNPathFinder extends ParserATNSimulator<Token> {
|
|||
|
||||
int n = s.getNumberOfTransitions();
|
||||
boolean aGoodPath = false;
|
||||
TraceTree found = null;
|
||||
TraceTree found;
|
||||
for (int j=0; j<n; j++) {
|
||||
Transition t = s.transition(j);
|
||||
if ( t.getClass() == RuleTransition.class ) {
|
||||
|
@ -165,7 +165,7 @@ public class ParserATNPathFinder extends ParserATNSimulator<Token> {
|
|||
TraceTree root, Transition t)
|
||||
{
|
||||
SemanticContext.Predicate pred = ((PredicateTransition) t).getPredicate();
|
||||
boolean pass = false;
|
||||
boolean pass;
|
||||
if ( pred.isCtxDependent ) {
|
||||
if ( ctx instanceof ParserRuleContext && ctx==initialContext ) {
|
||||
System.out.println("eval pred "+pred+"="+pred.eval(parser, ctx));
|
||||
|
|
|
@ -90,8 +90,8 @@ public class LogManager {
|
|||
}
|
||||
|
||||
public String save() throws IOException {
|
||||
String dir = System.getProperty("java.io.tmpdir");
|
||||
dir = ".";
|
||||
//String dir = System.getProperty("java.io.tmpdir");
|
||||
String dir = ".";
|
||||
String defaultFilename =
|
||||
dir + "/antlr-" +
|
||||
new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss").format(new Date()) + ".log";
|
||||
|
|
|
@ -127,7 +127,7 @@ public class TestRig {
|
|||
// System.out.println("exec "+grammarName+"."+startRuleName);
|
||||
String lexerName = grammarName+"Lexer";
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
Class lexerClass = null;
|
||||
Class lexerClass;
|
||||
try {
|
||||
lexerClass = cl.loadClass(lexerName);
|
||||
}
|
||||
|
|
|
@ -306,8 +306,8 @@ public class Tool {
|
|||
GrammarTransformPipeline transform = new GrammarTransformPipeline(g, this);
|
||||
transform.process();
|
||||
|
||||
LexerGrammar lexerg = null;
|
||||
GrammarRootAST lexerAST = null;
|
||||
LexerGrammar lexerg;
|
||||
GrammarRootAST lexerAST;
|
||||
if ( g.ast!=null && g.ast.grammarType== ANTLRParser.COMBINED &&
|
||||
!g.ast.hasErrors )
|
||||
{
|
||||
|
|
|
@ -115,7 +115,7 @@ public class LeftRecursiveRuleTransformer {
|
|||
String ruleName = prevRuleAST.getChild(0).getText();
|
||||
LeftRecursiveRuleAnalyzer leftRecursiveRuleWalker =
|
||||
new LeftRecursiveRuleAnalyzer(tokens, prevRuleAST, tool, ruleName, language);
|
||||
boolean isLeftRec = false;
|
||||
boolean isLeftRec;
|
||||
try {
|
||||
// System.out.println("TESTING ---------------\n"+
|
||||
// leftRecursiveRuleWalker.text(ruleAST));
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ATNPrinter {
|
|||
work.add(start);
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
ATNState s = null;
|
||||
ATNState s;
|
||||
|
||||
while ( !work.isEmpty() ) {
|
||||
s = work.remove(0);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class GrammarASTAdaptor extends CommonTreeAdaptor {
|
|||
@Override
|
||||
/** Make sure even imaginary nodes know the input stream */
|
||||
public Object create(int tokenType, String text) {
|
||||
GrammarAST t = null;
|
||||
GrammarAST t;
|
||||
if ( tokenType==ANTLRParser.RULE ) {
|
||||
// needed by TreeWizard to make RULE tree
|
||||
t = new RuleAST(new CommonToken(tokenType, text));
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ToolANTLRParser extends ANTLRParser {
|
|||
}
|
||||
|
||||
public String getParserErrorMessage(Parser parser, RecognitionException e) {
|
||||
String msg = null;
|
||||
String msg;
|
||||
if ( e instanceof NoViableAltException) {
|
||||
String name = parser.getTokenErrorDisplay(e.token);
|
||||
msg = name+" came as a complete surprise to me";
|
||||
|
|
|
@ -62,7 +62,7 @@ public class RuleCollector extends GrammarTreeVisitor {
|
|||
GrammarAST block)
|
||||
{
|
||||
int numAlts = block.getChildCount();
|
||||
Rule r = null;
|
||||
Rule r;
|
||||
if ( LeftRecursiveRuleAnalyzer.hasImmediateRecursiveRuleRefs(rule, ID.getText()) ) {
|
||||
r = new LeftRecursiveRule(g, ID.getText(), rule);
|
||||
}
|
||||
|
|
|
@ -103,8 +103,8 @@ public class SymbolChecks {
|
|||
public void checkActionRedefinitions(List<GrammarAST> actions) {
|
||||
if ( actions==null ) return;
|
||||
String scope = g.getDefaultActionScope();
|
||||
String name = null;
|
||||
GrammarAST nameNode = null;
|
||||
String name;
|
||||
GrammarAST nameNode;
|
||||
for (GrammarAST ampersandAST : actions) {
|
||||
nameNode = (GrammarAST)ampersandAST.getChild(0);
|
||||
if ( ampersandAST.getChildCount()==2 ) {
|
||||
|
|
|
@ -420,7 +420,7 @@ public class Grammar implements AttributeResolver {
|
|||
}
|
||||
|
||||
public int getTokenType(String token) {
|
||||
Integer I = null;
|
||||
Integer I;
|
||||
if ( token.charAt(0)=='\'') {
|
||||
I = stringLiteralToTypeMap.get(token);
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class Grammar implements AttributeResolver {
|
|||
* char vocabulary, compute an ANTLR-valid (possibly escaped) char literal.
|
||||
*/
|
||||
public String getTokenDisplayName(int ttype) {
|
||||
String tokenName = null;
|
||||
String tokenName;
|
||||
// inside any target's char range and is lexer grammar?
|
||||
if ( isLexer() &&
|
||||
ttype >= Lexer.MIN_CHAR_VALUE && ttype <= Lexer.MAX_CHAR_VALUE )
|
||||
|
@ -766,7 +766,7 @@ public class Grammar implements AttributeResolver {
|
|||
Tree name = r.getChild(0);
|
||||
if ( name.getType()==ANTLRParser.TOKEN_REF ) {
|
||||
// check rule against patterns
|
||||
boolean isLitRule = false;
|
||||
boolean isLitRule;
|
||||
for (String pattern : patterns) {
|
||||
isLitRule =
|
||||
defAlias(r, pattern, wiz, lexerRuleToStringLiteral);
|
||||
|
|
Loading…
Reference in New Issue