forked from jasder/antlr
reuse of -> label on multiple alts in rule caused dup ctx object defs.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9868]
This commit is contained in:
parent
093a4f951b
commit
491744f893
|
@ -4,6 +4,7 @@ Jan 14, 2012
|
|||
|
||||
* labels on tokens in left-recursive rules caused codegen exception.
|
||||
* leave start/stop char index alone in CommonTokenFactory; refers to original text.
|
||||
* reuse of -> label on multiple alts in rule caused dup ctx object defs.
|
||||
|
||||
Jan 11, 2012
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ import org.antlr.v4.tool.Grammar;
|
|||
import org.antlr.v4.tool.Rule;
|
||||
import org.antlr.v4.tool.ast.ActionAST;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** A model object representing a parse tree listener file.
|
||||
* These are the rules specific events triggered by a parse tree visitor.
|
||||
|
@ -14,7 +15,7 @@ import java.util.List;
|
|||
public class ListenerFile extends OutputFile {
|
||||
public String grammarName;
|
||||
public String parserName;
|
||||
public List<String> listenerNames = new ArrayList<String>();
|
||||
public Set<String> listenerNames = new HashSet<String>();
|
||||
// public List<String> ruleNames = new ArrayList<String>();
|
||||
|
||||
@ModelElement public Action header;
|
||||
|
|
|
@ -49,7 +49,6 @@ public class RuleFunction extends OutputModelObject {
|
|||
public String ctxType;
|
||||
public Collection<String> ruleLabels;
|
||||
public Collection<String> tokenLabels;
|
||||
public List<String> elementsReferencedInRewrite;
|
||||
public List<String> exceptions;
|
||||
public ATNState startState;
|
||||
public int index;
|
||||
|
@ -59,7 +58,7 @@ public class RuleFunction extends OutputModelObject {
|
|||
@ModelElement public List<SrcOp> code;
|
||||
@ModelElement public OrderedHashSet<Decl> locals; // TODO: move into ctx?
|
||||
@ModelElement public StructDecl ruleCtx;
|
||||
@ModelElement public List<AltLabelStructDecl> altLabelCtxs;
|
||||
@ModelElement public Set<AltLabelStructDecl> altLabelCtxs;
|
||||
@ModelElement public Map<String, Action> namedActions;
|
||||
@ModelElement public Action finallyAction;
|
||||
@ModelElement public List<SrcOp> postamble;
|
||||
|
@ -80,7 +79,7 @@ public class RuleFunction extends OutputModelObject {
|
|||
|
||||
List<String> labels = r.getAltLabels();
|
||||
if ( labels!=null ) {
|
||||
altLabelCtxs = new ArrayList<AltLabelStructDecl>();
|
||||
altLabelCtxs = new HashSet<AltLabelStructDecl>();
|
||||
for (String label : labels) {
|
||||
altLabelCtxs.add(new AltLabelStructDecl(factory, r, label));
|
||||
}
|
||||
|
|
|
@ -39,4 +39,19 @@ public class AltLabelStructDecl extends StructDecl {
|
|||
super(factory, r);
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return label.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ( obj == this ) return true;
|
||||
if ( obj.hashCode() != this.hashCode() ) return false;
|
||||
if ( obj instanceof AltLabelStructDecl ) {
|
||||
return label.equals(((AltLabelStructDecl)obj).label);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue