From 46e1bad7b489741b8e3a967be3aa73a55efe7c1d Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 31 May 2014 18:14:41 -0500 Subject: [PATCH] Simplify the GrammarAST constructors, and correct the token start/stop index not being set --- tool/src/org/antlr/v4/tool/ast/GrammarAST.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarAST.java b/tool/src/org/antlr/v4/tool/ast/GrammarAST.java index 0dc75db48..946f0ce32 100644 --- a/tool/src/org/antlr/v4/tool/ast/GrammarAST.java +++ b/tool/src/org/antlr/v4/tool/ast/GrammarAST.java @@ -67,18 +67,13 @@ public class GrammarAST extends CommonTree { } public GrammarAST(int type) { super(new CommonToken(type, ANTLRParser.tokenNames[type])); } public GrammarAST(int type, Token t) { - this(new CommonToken(type, t.getText())); - token.setInputStream(t.getInputStream()); - token.setLine(t.getLine()); - token.setCharPositionInLine(t.getCharPositionInLine()); - token.setTokenIndex(t.getTokenIndex()); + this(new CommonToken(t)); + token.setType(type); } public GrammarAST(int type, Token t, String text) { - this(new CommonToken(type, text)); - token.setInputStream(t.getInputStream()); - token.setLine(t.getLine()); - token.setCharPositionInLine(t.getCharPositionInLine()); - token.setTokenIndex(t.getTokenIndex()); + this(new CommonToken(t)); + token.setType(type); + token.setText(text); } public GrammarAST[] getChildrenAsArray() {