From d041a4828a4c8c95014cb25c875cfc1f9f4683ad Mon Sep 17 00:00:00 2001 From: Terence Parr Date: Wed, 7 Aug 2013 11:50:04 -0700 Subject: [PATCH] fix poor function name: setTokenAssoc --- .../v4/analysis/LeftRecursiveRuleAnalyzer.java | 2 +- .../org/antlr/v4/parse/LeftRecursiveRuleWalker.g | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java index 9f6b5f226..77e58cf3a 100644 --- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java +++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java @@ -115,7 +115,7 @@ public class LeftRecursiveRuleAnalyzer extends LeftRecursiveRuleWalker { } @Override - public void setTokenPrec(GrammarAST t, int alt) { + public void setTokenAssoc(GrammarAST t, int alt) { ASSOC assoc = ASSOC.left; if ( t instanceof GrammarASTWithOptions ) { if ( ((GrammarASTWithOptions)t).getOptions()!=null ) { diff --git a/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g b/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g index 011e2cf27..039910dcf 100644 --- a/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g +++ b/tool/src/org/antlr/v4/parse/LeftRecursiveRuleWalker.g @@ -49,7 +49,7 @@ private String ruleName; private int currentOuterAltNumber; // which outer alt of rule? public int numAlts; // how many alts for this rule total? -public void setTokenPrec(GrammarAST t, int alt) {} +public void setTokenAssoc(GrammarAST t, int alt) {} public void binaryAlt(AltAST altTree, int alt) {} public void ternaryAlt(AltAST altTree, int alt) {} public void prefixAlt(AltAST altTree, int alt) {} @@ -132,26 +132,26 @@ binaryMultipleOp ; bops: ^(ASSIGN ID bops) - | ^( BLOCK ( ^( ALT (op=token)+ {setTokenPrec($op.t, currentOuterAltNumber);} ) )+ ) - | ^(SET (op=token)+ {setTokenPrec($op.t, currentOuterAltNumber);}) + | ^( BLOCK ( ^( ALT (op=token)+ {setTokenAssoc($op.t, currentOuterAltNumber);} ) )+ ) + | ^(SET (op=token)+ {setTokenAssoc($op.t, currentOuterAltNumber);}) ; binary - : ^( ALT recurse (op=token)+ {setTokenPrec($op.t, currentOuterAltNumber);} recurse ACTION? ) + : ^( ALT recurse (op=token)+ {setTokenAssoc($op.t, currentOuterAltNumber);} recurse ACTION? ) ; ternary - : ^( ALT recurse op=token recurse token recurse ACTION? ) {setTokenPrec($op.t, currentOuterAltNumber);} + : ^( ALT recurse op=token recurse token recurse ACTION? ) {setTokenAssoc($op.t, currentOuterAltNumber);} ; prefix - : ^( ALT {setTokenPrec((GrammarAST)input.LT(1), currentOuterAltNumber);} + : ^( ALT {setTokenAssoc((GrammarAST)input.LT(1), currentOuterAltNumber);} ({!((CommonTree)input.LT(1)).getText().equals(ruleName)}? element)+ recurse ACTION? ) ; -suffix : ^( ALT recurse {setTokenPrec((GrammarAST)input.LT(1), currentOuterAltNumber);} element+ ) ; +suffix : ^( ALT recurse {setTokenAssoc((GrammarAST)input.LT(1), currentOuterAltNumber);} element+ ) ; recurse : ^(ASSIGN ID recurseNoLabel)