Updated parameter types of copy constructors, return types of dupNode
This commit is contained in:
parent
9d3c763470
commit
356b8e4b27
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
import org.antlr.v4.tool.AttributeResolver;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -41,10 +40,10 @@ public class ActionAST extends GrammarASTWithOptions implements RuleElementAST {
|
|||
public AttributeResolver resolver;
|
||||
public List<Token> chunks; // useful for ANTLR IDE developers
|
||||
|
||||
public ActionAST(GrammarAST node) {
|
||||
public ActionAST(ActionAST node) {
|
||||
super(node);
|
||||
this.resolver = ((ActionAST)node).resolver;
|
||||
this.chunks = ((ActionAST)node).chunks;
|
||||
this.resolver = node.resolver;
|
||||
this.chunks = node.chunks;
|
||||
}
|
||||
|
||||
public ActionAST(Token t) { super(t); }
|
||||
|
@ -52,7 +51,7 @@ public class ActionAST extends GrammarASTWithOptions implements RuleElementAST {
|
|||
public ActionAST(int type, Token t) { super(type, t); }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new ActionAST(this); }
|
||||
public ActionAST dupNode() { return new ActionAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
import org.antlr.v4.analysis.LeftRecursiveRuleAltInfo;
|
||||
import org.antlr.v4.tool.Alternative;
|
||||
|
||||
|
@ -47,11 +46,11 @@ public class AltAST extends GrammarAST {
|
|||
*/
|
||||
public GrammarAST altLabel;
|
||||
|
||||
public AltAST(GrammarAST node) {
|
||||
public AltAST(AltAST node) {
|
||||
super(node);
|
||||
this.alt = ((AltAST)node).alt;
|
||||
this.altLabel = ((AltAST)node).altLabel;
|
||||
this.leftRecursiveAltInfo = ((AltAST)node).leftRecursiveAltInfo;
|
||||
this.alt = node.alt;
|
||||
this.altLabel = node.altLabel;
|
||||
this.leftRecursiveAltInfo = node.leftRecursiveAltInfo;
|
||||
}
|
||||
|
||||
public AltAST(Token t) { super(t); }
|
||||
|
@ -60,7 +59,7 @@ public class AltAST extends GrammarAST {
|
|||
public AltAST(int type, Token t, String text) { super(type,t,text); }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new AltAST(this); }
|
||||
public AltAST dupNode() { return new AltAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -45,7 +44,7 @@ public class BlockAST extends GrammarASTWithOptions implements RuleElementAST {
|
|||
public static final Map<String, String> defaultLexerBlockOptions =
|
||||
new HashMap<String, String>();
|
||||
|
||||
public BlockAST(GrammarAST node) {
|
||||
public BlockAST(BlockAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,7 @@ public class BlockAST extends GrammarASTWithOptions implements RuleElementAST {
|
|||
public BlockAST(int type, Token t, String text) { super(type,t,text); }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new BlockAST(this); }
|
||||
public BlockAST dupNode() { return new BlockAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -213,7 +213,7 @@ public class GrammarAST extends CommonTree {
|
|||
// }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() {
|
||||
public GrammarAST dupNode() {
|
||||
return new GrammarAST(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ import java.util.Map;
|
|||
public abstract class GrammarASTWithOptions extends GrammarAST {
|
||||
protected Map<String, GrammarAST> options;
|
||||
|
||||
public GrammarASTWithOptions(GrammarAST node) {
|
||||
public GrammarASTWithOptions(GrammarASTWithOptions node) {
|
||||
super(node);
|
||||
this.options = ((GrammarASTWithOptions)node).options;
|
||||
this.options = node.options;
|
||||
}
|
||||
|
||||
public GrammarASTWithOptions(Token t) { super(t); }
|
||||
|
@ -81,5 +81,8 @@ public abstract class GrammarASTWithOptions extends GrammarAST {
|
|||
return options==null ? 0 : options.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract GrammarASTWithOptions dupNode();
|
||||
|
||||
public Map<String, GrammarAST> getOptions() { return options; }
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@ public class GrammarRootAST extends GrammarASTWithOptions {
|
|||
public Map<String, String> cmdLineOptions; // -DsuperClass=T on command line
|
||||
public String fileName;
|
||||
|
||||
public GrammarRootAST(GrammarAST node) {
|
||||
public GrammarRootAST(GrammarRootAST node) {
|
||||
super(node);
|
||||
this.grammarType = ((GrammarRootAST)node).grammarType;
|
||||
this.hasErrors = ((GrammarRootAST)node).hasErrors;
|
||||
this.grammarType = node.grammarType;
|
||||
this.hasErrors = node.hasErrors;
|
||||
}
|
||||
|
||||
public GrammarRootAST(int type) { super(type); }
|
||||
|
@ -84,5 +84,5 @@ public class GrammarRootAST extends GrammarASTWithOptions {
|
|||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new GrammarRootAST(this); }
|
||||
public GrammarRootAST dupNode() { return new GrammarRootAST(this); }
|
||||
}
|
||||
|
|
|
@ -33,8 +33,18 @@ package org.antlr.v4.tool.ast;
|
|||
import org.antlr.runtime.Token;
|
||||
|
||||
public class NotAST extends GrammarAST implements RuleElementAST {
|
||||
|
||||
public NotAST(NotAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public NotAST(int type, Token t) { super(type, t); }
|
||||
|
||||
@Override
|
||||
public NotAST dupNode() {
|
||||
return new NotAST(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
public class OptionalBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST {
|
||||
private final boolean _greedy;
|
||||
|
@ -52,7 +51,7 @@ public class OptionalBlockAST extends GrammarAST implements RuleElementAST, Quan
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new OptionalBlockAST(this); }
|
||||
public OptionalBlockAST dupNode() { return new OptionalBlockAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
public class PlusBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST {
|
||||
private final boolean _greedy;
|
||||
|
@ -52,7 +51,7 @@ public class PlusBlockAST extends GrammarAST implements RuleElementAST, Quantifi
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new PlusBlockAST(this); }
|
||||
public PlusBlockAST dupNode() { return new PlusBlockAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -31,10 +31,9 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
public class PredAST extends ActionAST {
|
||||
public PredAST(GrammarAST node) {
|
||||
public PredAST(PredAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
@ -43,7 +42,7 @@ public class PredAST extends ActionAST {
|
|||
public PredAST(int type, Token t) { super(type, t); }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new PredAST(this); }
|
||||
public PredAST dupNode() { return new PredAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -33,8 +33,18 @@ package org.antlr.v4.tool.ast;
|
|||
import org.antlr.runtime.Token;
|
||||
|
||||
public class RangeAST extends GrammarAST implements RuleElementAST {
|
||||
|
||||
public RangeAST(RangeAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public RangeAST(Token t) { super(t); }
|
||||
|
||||
@Override
|
||||
public RangeAST dupNode() {
|
||||
return new RangeAST(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class RuleAST extends GrammarASTWithOptions {
|
|||
/** Kill redef of rules */
|
||||
public boolean dead;
|
||||
|
||||
public RuleAST(GrammarAST node) {
|
||||
public RuleAST(RuleAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class RuleAST extends GrammarASTWithOptions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new RuleAST(this); }
|
||||
public RuleAST dupNode() { return new RuleAST(this); }
|
||||
|
||||
public ActionAST getLexerAction() {
|
||||
Tree blk = getFirstChildWithType(ANTLRParser.BLOCK);
|
||||
|
|
|
@ -32,10 +32,9 @@ package org.antlr.v4.tool.ast;
|
|||
|
||||
import org.antlr.runtime.CommonToken;
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST {
|
||||
public RuleRefAST(GrammarAST node) {
|
||||
public RuleRefAST(RuleRefAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
@ -45,7 +44,7 @@ public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST
|
|||
|
||||
/** Dup token too since we overwrite during LR rule transform */
|
||||
@Override
|
||||
public Tree dupNode() {
|
||||
public RuleRefAST dupNode() {
|
||||
RuleRefAST r = new RuleRefAST(this);
|
||||
// In LR transform, we alter original token stream to make e -> e[n]
|
||||
// Since we will be altering the dup, we need dup to have the
|
||||
|
|
|
@ -33,8 +33,18 @@ package org.antlr.v4.tool.ast;
|
|||
import org.antlr.runtime.Token;
|
||||
|
||||
public class SetAST extends GrammarAST implements RuleElementAST {
|
||||
|
||||
public SetAST(SetAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public SetAST(int type, Token t, String text) { super(type,t,text); }
|
||||
|
||||
@Override
|
||||
public SetAST dupNode() {
|
||||
return new SetAST(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
public class StarBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST {
|
||||
private final boolean _greedy;
|
||||
|
@ -52,7 +51,7 @@ public class StarBlockAST extends GrammarAST implements RuleElementAST, Quantifi
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new StarBlockAST(this); }
|
||||
public StarBlockAST dupNode() { return new StarBlockAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
|
@ -31,11 +31,10 @@
|
|||
package org.antlr.v4.tool.ast;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
||||
public class TerminalAST extends GrammarASTWithOptions implements RuleElementAST {
|
||||
|
||||
public TerminalAST(GrammarAST node) {
|
||||
public TerminalAST(TerminalAST node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
@ -44,7 +43,7 @@ public class TerminalAST extends GrammarASTWithOptions implements RuleElementAST
|
|||
public TerminalAST(int type, Token t) { super(type, t); }
|
||||
|
||||
@Override
|
||||
public Tree dupNode() { return new TerminalAST(this); }
|
||||
public TerminalAST dupNode() { return new TerminalAST(this); }
|
||||
|
||||
@Override
|
||||
public Object visit(GrammarASTVisitor v) { return v.visit(this); }
|
||||
|
|
Loading…
Reference in New Issue