Merge pull request #585 from sharwell/grammar-ast

Simplify the GrammarAST constructors
This commit is contained in:
Terence Parr 2014-05-31 16:48:20 -07:00
commit 43b04f02f6
1 changed files with 5 additions and 10 deletions

View File

@ -67,18 +67,13 @@ public class GrammarAST extends CommonTree {
} }
public GrammarAST(int type) { super(new CommonToken(type, ANTLRParser.tokenNames[type])); } public GrammarAST(int type) { super(new CommonToken(type, ANTLRParser.tokenNames[type])); }
public GrammarAST(int type, Token t) { public GrammarAST(int type, Token t) {
this(new CommonToken(type, t.getText())); this(new CommonToken(t));
token.setInputStream(t.getInputStream()); token.setType(type);
token.setLine(t.getLine());
token.setCharPositionInLine(t.getCharPositionInLine());
token.setTokenIndex(t.getTokenIndex());
} }
public GrammarAST(int type, Token t, String text) { public GrammarAST(int type, Token t, String text) {
this(new CommonToken(type, text)); this(new CommonToken(t));
token.setInputStream(t.getInputStream()); token.setType(type);
token.setLine(t.getLine()); token.setText(text);
token.setCharPositionInLine(t.getCharPositionInLine());
token.setTokenIndex(t.getTokenIndex());
} }
public GrammarAST[] getChildrenAsArray() { public GrammarAST[] getChildrenAsArray() {