Updated parameter types of copy constructors, return types of dupNode

This commit is contained in:
Sam Harwell 2012-12-07 08:31:38 -06:00
parent 9d3c763470
commit 356b8e4b27
16 changed files with 62 additions and 38 deletions

View File

@ -31,7 +31,6 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
import org.antlr.v4.tool.AttributeResolver; import org.antlr.v4.tool.AttributeResolver;
import java.util.List; import java.util.List;
@ -41,10 +40,10 @@ public class ActionAST extends GrammarASTWithOptions implements RuleElementAST {
public AttributeResolver resolver; public AttributeResolver resolver;
public List<Token> chunks; // useful for ANTLR IDE developers public List<Token> chunks; // useful for ANTLR IDE developers
public ActionAST(GrammarAST node) { public ActionAST(ActionAST node) {
super(node); super(node);
this.resolver = ((ActionAST)node).resolver; this.resolver = node.resolver;
this.chunks = ((ActionAST)node).chunks; this.chunks = node.chunks;
} }
public ActionAST(Token t) { super(t); } 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); } public ActionAST(int type, Token t) { super(type, t); }
@Override @Override
public Tree dupNode() { return new ActionAST(this); } public ActionAST dupNode() { return new ActionAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -31,7 +31,6 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
import org.antlr.v4.analysis.LeftRecursiveRuleAltInfo; import org.antlr.v4.analysis.LeftRecursiveRuleAltInfo;
import org.antlr.v4.tool.Alternative; import org.antlr.v4.tool.Alternative;
@ -47,11 +46,11 @@ public class AltAST extends GrammarAST {
*/ */
public GrammarAST altLabel; public GrammarAST altLabel;
public AltAST(GrammarAST node) { public AltAST(AltAST node) {
super(node); super(node);
this.alt = ((AltAST)node).alt; this.alt = node.alt;
this.altLabel = ((AltAST)node).altLabel; this.altLabel = node.altLabel;
this.leftRecursiveAltInfo = ((AltAST)node).leftRecursiveAltInfo; this.leftRecursiveAltInfo = node.leftRecursiveAltInfo;
} }
public AltAST(Token t) { super(t); } 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); } public AltAST(int type, Token t, String text) { super(type,t,text); }
@Override @Override
public Tree dupNode() { return new AltAST(this); } public AltAST dupNode() { return new AltAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -31,7 +31,6 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -45,7 +44,7 @@ public class BlockAST extends GrammarASTWithOptions implements RuleElementAST {
public static final Map<String, String> defaultLexerBlockOptions = public static final Map<String, String> defaultLexerBlockOptions =
new HashMap<String, String>(); new HashMap<String, String>();
public BlockAST(GrammarAST node) { public BlockAST(BlockAST node) {
super(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); } public BlockAST(int type, Token t, String text) { super(type,t,text); }
@Override @Override
public Tree dupNode() { return new BlockAST(this); } public BlockAST dupNode() { return new BlockAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -213,7 +213,7 @@ public class GrammarAST extends CommonTree {
// } // }
@Override @Override
public Tree dupNode() { public GrammarAST dupNode() {
return new GrammarAST(this); return new GrammarAST(this);
} }

View File

@ -39,9 +39,9 @@ import java.util.Map;
public abstract class GrammarASTWithOptions extends GrammarAST { public abstract class GrammarASTWithOptions extends GrammarAST {
protected Map<String, GrammarAST> options; protected Map<String, GrammarAST> options;
public GrammarASTWithOptions(GrammarAST node) { public GrammarASTWithOptions(GrammarASTWithOptions node) {
super(node); super(node);
this.options = ((GrammarASTWithOptions)node).options; this.options = node.options;
} }
public GrammarASTWithOptions(Token t) { super(t); } public GrammarASTWithOptions(Token t) { super(t); }
@ -81,5 +81,8 @@ public abstract class GrammarASTWithOptions extends GrammarAST {
return options==null ? 0 : options.size(); return options==null ? 0 : options.size();
} }
@Override
public abstract GrammarASTWithOptions dupNode();
public Map<String, GrammarAST> getOptions() { return options; } public Map<String, GrammarAST> getOptions() { return options; }
} }

View File

@ -49,10 +49,10 @@ public class GrammarRootAST extends GrammarASTWithOptions {
public Map<String, String> cmdLineOptions; // -DsuperClass=T on command line public Map<String, String> cmdLineOptions; // -DsuperClass=T on command line
public String fileName; public String fileName;
public GrammarRootAST(GrammarAST node) { public GrammarRootAST(GrammarRootAST node) {
super(node); super(node);
this.grammarType = ((GrammarRootAST)node).grammarType; this.grammarType = node.grammarType;
this.hasErrors = ((GrammarRootAST)node).hasErrors; this.hasErrors = node.hasErrors;
} }
public GrammarRootAST(int type) { super(type); } public GrammarRootAST(int type) { super(type); }
@ -84,5 +84,5 @@ public class GrammarRootAST extends GrammarASTWithOptions {
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }
@Override @Override
public Tree dupNode() { return new GrammarRootAST(this); } public GrammarRootAST dupNode() { return new GrammarRootAST(this); }
} }

View File

@ -33,8 +33,18 @@ package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
public class NotAST extends GrammarAST implements RuleElementAST { public class NotAST extends GrammarAST implements RuleElementAST {
public NotAST(NotAST node) {
super(node);
}
public NotAST(int type, Token t) { super(type, t); } public NotAST(int type, Token t) { super(type, t); }
@Override
public NotAST dupNode() {
return new NotAST(this);
}
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }
} }

View File

@ -31,7 +31,6 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
public class OptionalBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST { public class OptionalBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST {
private final boolean _greedy; private final boolean _greedy;
@ -52,7 +51,7 @@ public class OptionalBlockAST extends GrammarAST implements RuleElementAST, Quan
} }
@Override @Override
public Tree dupNode() { return new OptionalBlockAST(this); } public OptionalBlockAST dupNode() { return new OptionalBlockAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -31,7 +31,6 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
public class PlusBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST { public class PlusBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST {
private final boolean _greedy; private final boolean _greedy;
@ -52,7 +51,7 @@ public class PlusBlockAST extends GrammarAST implements RuleElementAST, Quantifi
} }
@Override @Override
public Tree dupNode() { return new PlusBlockAST(this); } public PlusBlockAST dupNode() { return new PlusBlockAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -31,10 +31,9 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
public class PredAST extends ActionAST { public class PredAST extends ActionAST {
public PredAST(GrammarAST node) { public PredAST(PredAST node) {
super(node); super(node);
} }
@ -43,7 +42,7 @@ public class PredAST extends ActionAST {
public PredAST(int type, Token t) { super(type, t); } public PredAST(int type, Token t) { super(type, t); }
@Override @Override
public Tree dupNode() { return new PredAST(this); } public PredAST dupNode() { return new PredAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -33,8 +33,18 @@ package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
public class RangeAST extends GrammarAST implements RuleElementAST { public class RangeAST extends GrammarAST implements RuleElementAST {
public RangeAST(RangeAST node) {
super(node);
}
public RangeAST(Token t) { super(t); } public RangeAST(Token t) { super(t); }
@Override
public RangeAST dupNode() {
return new RangeAST(this);
}
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }
} }

View File

@ -39,7 +39,7 @@ public class RuleAST extends GrammarASTWithOptions {
/** Kill redef of rules */ /** Kill redef of rules */
public boolean dead; public boolean dead;
public RuleAST(GrammarAST node) { public RuleAST(RuleAST node) {
super(node); super(node);
} }
@ -58,7 +58,7 @@ public class RuleAST extends GrammarASTWithOptions {
} }
@Override @Override
public Tree dupNode() { return new RuleAST(this); } public RuleAST dupNode() { return new RuleAST(this); }
public ActionAST getLexerAction() { public ActionAST getLexerAction() {
Tree blk = getFirstChildWithType(ANTLRParser.BLOCK); Tree blk = getFirstChildWithType(ANTLRParser.BLOCK);

View File

@ -32,10 +32,9 @@ package org.antlr.v4.tool.ast;
import org.antlr.runtime.CommonToken; import org.antlr.runtime.CommonToken;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST { public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST {
public RuleRefAST(GrammarAST node) { public RuleRefAST(RuleRefAST node) {
super(node); super(node);
} }
@ -45,7 +44,7 @@ public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST
/** Dup token too since we overwrite during LR rule transform */ /** Dup token too since we overwrite during LR rule transform */
@Override @Override
public Tree dupNode() { public RuleRefAST dupNode() {
RuleRefAST r = new RuleRefAST(this); RuleRefAST r = new RuleRefAST(this);
// In LR transform, we alter original token stream to make e -> e[n] // 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 // Since we will be altering the dup, we need dup to have the

View File

@ -33,8 +33,18 @@ package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
public class SetAST extends GrammarAST implements RuleElementAST { 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); } public SetAST(int type, Token t, String text) { super(type,t,text); }
@Override
public SetAST dupNode() {
return new SetAST(this);
}
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }
} }

View File

@ -31,7 +31,6 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
public class StarBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST { public class StarBlockAST extends GrammarAST implements RuleElementAST, QuantifierAST {
private final boolean _greedy; private final boolean _greedy;
@ -52,7 +51,7 @@ public class StarBlockAST extends GrammarAST implements RuleElementAST, Quantifi
} }
@Override @Override
public Tree dupNode() { return new StarBlockAST(this); } public StarBlockAST dupNode() { return new StarBlockAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }

View File

@ -31,11 +31,10 @@
package org.antlr.v4.tool.ast; package org.antlr.v4.tool.ast;
import org.antlr.runtime.Token; import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;
public class TerminalAST extends GrammarASTWithOptions implements RuleElementAST { public class TerminalAST extends GrammarASTWithOptions implements RuleElementAST {
public TerminalAST(GrammarAST node) { public TerminalAST(TerminalAST node) {
super(node); super(node);
} }
@ -44,7 +43,7 @@ public class TerminalAST extends GrammarASTWithOptions implements RuleElementAST
public TerminalAST(int type, Token t) { super(type, t); } public TerminalAST(int type, Token t) { super(type, t); }
@Override @Override
public Tree dupNode() { return new TerminalAST(this); } public TerminalAST dupNode() { return new TerminalAST(this); }
@Override @Override
public Object visit(GrammarASTVisitor v) { return v.visit(this); } public Object visit(GrammarASTVisitor v) { return v.visit(this); }