fix poor function name: setTokenAssoc

This commit is contained in:
Terence Parr 2013-08-07 11:50:04 -07:00 committed by Sam Harwell
parent 274120c2b6
commit d041a4828a
2 changed files with 8 additions and 8 deletions

View File

@ -115,7 +115,7 @@ public class LeftRecursiveRuleAnalyzer extends LeftRecursiveRuleWalker {
} }
@Override @Override
public void setTokenPrec(GrammarAST t, int alt) { public void setTokenAssoc(GrammarAST t, int alt) {
ASSOC assoc = ASSOC.left; ASSOC assoc = ASSOC.left;
if ( t instanceof GrammarASTWithOptions ) { if ( t instanceof GrammarASTWithOptions ) {
if ( ((GrammarASTWithOptions)t).getOptions()!=null ) { if ( ((GrammarASTWithOptions)t).getOptions()!=null ) {

View File

@ -49,7 +49,7 @@ private String ruleName;
private int currentOuterAltNumber; // which outer alt of rule? private int currentOuterAltNumber; // which outer alt of rule?
public int numAlts; // how many alts for this rule total? 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 binaryAlt(AltAST altTree, int alt) {}
public void ternaryAlt(AltAST altTree, int alt) {} public void ternaryAlt(AltAST altTree, int alt) {}
public void prefixAlt(AltAST altTree, int alt) {} public void prefixAlt(AltAST altTree, int alt) {}
@ -132,26 +132,26 @@ binaryMultipleOp
; ;
bops: ^(ASSIGN ID bops) bops: ^(ASSIGN ID bops)
| ^( BLOCK ( ^( ALT (op=token)+ {setTokenPrec($op.t, currentOuterAltNumber);} ) )+ ) | ^( BLOCK ( ^( ALT (op=token)+ {setTokenAssoc($op.t, currentOuterAltNumber);} ) )+ )
| ^(SET (op=token)+ {setTokenPrec($op.t, currentOuterAltNumber);}) | ^(SET (op=token)+ {setTokenAssoc($op.t, currentOuterAltNumber);})
; ;
binary binary
: ^( ALT recurse (op=token)+ {setTokenPrec($op.t, currentOuterAltNumber);} recurse ACTION? ) : ^( ALT recurse (op=token)+ {setTokenAssoc($op.t, currentOuterAltNumber);} recurse ACTION? )
; ;
ternary 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 prefix
: ^( ALT {setTokenPrec((GrammarAST)input.LT(1), currentOuterAltNumber);} : ^( ALT {setTokenAssoc((GrammarAST)input.LT(1), currentOuterAltNumber);}
({!((CommonTree)input.LT(1)).getText().equals(ruleName)}? element)+ ({!((CommonTree)input.LT(1)).getText().equals(ruleName)}? element)+
recurse ACTION? recurse ACTION?
) )
; ;
suffix : ^( ALT recurse {setTokenPrec((GrammarAST)input.LT(1), currentOuterAltNumber);} element+ ) ; suffix : ^( ALT recurse {setTokenAssoc((GrammarAST)input.LT(1), currentOuterAltNumber);} element+ ) ;
recurse recurse
: ^(ASSIGN ID recurseNoLabel) : ^(ASSIGN ID recurseNoLabel)