protected void initContextTrees(int numberOfAlts) { contextTrees = new NFAContext[numberOfAlts]; for (int i = 0; i < contextTrees.length; i++) { int alt = i+1; // add a dummy root node so that an NFA configuration can // always point at an NFAContext. If a context refers to this // node then it implies there is no call stack for // that configuration contextTrees[i] = new NFAContext(null, null); } }
/** An NFA configuration is equal to another if both have * the same state, the predict the same alternative, and * syntactic/semantic contexts are the same. I don't think * the state|alt|ctx could be the same and have two different * semantic contexts, but might as well define equals to be * everything. */ @Override public boolean equals(Object o) { if ( o==null ) { return false; } NFAConfiguration other = (NFAConfiguration)o; return this.state==other.state && this.alt==other.alt && this.context.equals(other.context)&& this.semanticContext.equals(other.semanticContext); }
@Override public int hashCode() { int h = state + alt + context.hashCode(); return h; }
int depth = context.recursionDepthEmanatingFromState(p.stateNumber); NFAContext newContext = new NFAContext(context, p);
/** Two contexts conflict() if they are equals() or one is a stack suffix * of the other. For example, contexts [21 12 $] and [21 9 $] do not * conflict, but [21 $] and [21 12 $] do conflict. Note that I should * probably not show the $ in this case. There is a dummy node for each * stack that just means empty; $ is a marker that's all. * * This is used in relation to checking conflicts associated with a * single NFA state's configurations within a single DFA state. * If there are configurations s and t within a DFA state such that * s.state=t.state && s.alt != t.alt && s.ctx conflicts t.ctx then * the DFA state predicts more than a single alt--it's nondeterministic. * Two contexts conflict if they are the same or if one is a suffix * of the other. * * When comparing contexts, if one context has a stack and the other * does not then they should be considered the same context. The only * way for an NFA state p to have an empty context and a nonempty context * is the case when closure falls off end of rule without a call stack * and re-enters the rule with a context. This resolves the issue I * discussed with Sriram Srinivasan Feb 28, 2005 about not terminating * fast enough upon nondeterminism. */ public boolean conflictsWith(NFAContext other) { return this.suffix(other); // || this.equals(other); }
if ( s.alt != t.alt && s.context.conflictsWith(t.context) ) { nondeterministicAlts.add(Utils.integer(s.alt)); nondeterministicAlts.add(Utils.integer(t.alt));
int depth = context.recursionDepthEmanatingFromState(p.stateNumber); NFAContext newContext = new NFAContext(context, p);
/** Two contexts conflict() if they are equals() or one is a stack suffix * of the other. For example, contexts [21 12 $] and [21 9 $] do not * conflict, but [21 $] and [21 12 $] do conflict. Note that I should * probably not show the $ in this case. There is a dummy node for each * stack that just means empty; $ is a marker that's all. * * This is used in relation to checking conflicts associated with a * single NFA state's configurations within a single DFA state. * If there are configurations s and t within a DFA state such that * s.state=t.state && s.alt != t.alt && s.ctx conflicts t.ctx then * the DFA state predicts more than a single alt--it's nondeterministic. * Two contexts conflict if they are the same or if one is a suffix * of the other. * * When comparing contexts, if one context has a stack and the other * does not then they should be considered the same context. The only * way for an NFA state p to have an empty context and a nonempty context * is the case when closure falls off end of rule without a call stack * and re-enters the rule with a context. This resolves the issue I * discussed with Sriram Srinivasan Feb 28, 2005 about not terminating * fast enough upon nondeterminism. */ public boolean conflictsWith(NFAContext other) { return this.suffix(other); // || this.equals(other); }
if ( s.alt != t.alt && s.context.conflictsWith(t.context) ) { nondeterministicAlts.add(Utils.integer(s.alt)); nondeterministicAlts.add(Utils.integer(t.alt));
int depth = context.recursionDepthEmanatingFromState(p.stateNumber); NFAContext newContext = new NFAContext(context, p);
public int hashCode() { int h = state + alt + context.hashCode(); return h; }
protected void initContextTrees(int numberOfAlts) { contextTrees = new NFAContext[numberOfAlts]; for (int i = 0; i < contextTrees.length; i++) { int alt = i+1; // add a dummy root node so that an NFA configuration can // always point at an NFAContext. If a context refers to this // node then it implies there is no call stack for // that configuration contextTrees[i] = new NFAContext(null, null); } }
/** An NFA configuration is equal to another if both have * the same state, the predict the same alternative, and * syntactic/semantic contexts are the same. I don't think * the state|alt|ctx could be the same and have two different * semantic contexts, but might as well define equals to be * everything. */ public boolean equals(Object o) { if ( o==null ) { return false; } NFAConfiguration other = (NFAConfiguration)o; return this.state==other.state && this.alt==other.alt && this.context.equals(other.context)&& this.semanticContext.equals(other.semanticContext); }
/** Two contexts conflict() if they are equals() or one is a stack suffix * of the other. For example, contexts [21 12 $] and [21 9 $] do not * conflict, but [21 $] and [21 12 $] do conflict. Note that I should * probably not show the $ in this case. There is a dummy node for each * stack that just means empty; $ is a marker that's all. * * This is used in relation to checking conflicts associated with a * single NFA state's configurations within a single DFA state. * If there are configurations s and t within a DFA state such that * s.state=t.state && s.alt != t.alt && s.ctx conflicts t.ctx then * the DFA state predicts more than a single alt--it's nondeterministic. * Two contexts conflict if they are the same or if one is a suffix * of the other. * * When comparing contexts, if one context has a stack and the other * does not then they should be considered the same context. The only * way for an NFA state p to have an empty context and a nonempty context * is the case when closure falls off end of rule without a call stack * and re-enters the rule with a context. This resolves the issue I * discussed with Sriram Srinivasan Feb 28, 2005 about not terminating * fast enough upon nondeterminism. */ public boolean conflictsWith(NFAContext other) { return this.suffix(other); // || this.equals(other); }
if ( s.alt != t.alt && s.context.conflictsWith(t.context) ) { nondeterministicAlts.add(Utils.integer(s.alt)); nondeterministicAlts.add(Utils.integer(t.alt));
int depth = context.recursionDepthEmanatingFromState(p.stateNumber); NFAContext newContext = new NFAContext(context, p);
@Override public int hashCode() { int h = state + alt + context.hashCode(); return h; }
protected void initContextTrees(int numberOfAlts) { contextTrees = new NFAContext[numberOfAlts]; for (int i = 0; i < contextTrees.length; i++) { int alt = i+1; // add a dummy root node so that an NFA configuration can // always point at an NFAContext. If a context refers to this // node then it implies there is no call stack for // that configuration contextTrees[i] = new NFAContext(null, null); } }
/** An NFA configuration is equal to another if both have * the same state, the predict the same alternative, and * syntactic/semantic contexts are the same. I don't think * the state|alt|ctx could be the same and have two different * semantic contexts, but might as well define equals to be * everything. */ public boolean equals(Object o) { if ( o==null ) { return false; } NFAConfiguration other = (NFAConfiguration)o; return this.state==other.state && this.alt==other.alt && this.context.equals(other.context)&& this.semanticContext.equals(other.semanticContext); }
/** Two contexts conflict() if they are equals() or one is a stack suffix * of the other. For example, contexts [21 12 $] and [21 9 $] do not * conflict, but [21 $] and [21 12 $] do conflict. Note that I should * probably not show the $ in this case. There is a dummy node for each * stack that just means empty; $ is a marker that's all. * * This is used in relation to checking conflicts associated with a * single NFA state's configurations within a single DFA state. * If there are configurations s and t within a DFA state such that * s.state=t.state && s.alt != t.alt && s.ctx conflicts t.ctx then * the DFA state predicts more than a single alt--it's nondeterministic. * Two contexts conflict if they are the same or if one is a suffix * of the other. * * When comparing contexts, if one context has a stack and the other * does not then they should be considered the same context. The only * way for an NFA state p to have an empty context and a nonempty context * is the case when closure falls off end of rule without a call stack * and re-enters the rule with a context. This resolves the issue I * discussed with Sriram Srinivasan Feb 28, 2005 about not terminating * fast enough upon nondeterminism. */ public boolean conflictsWith(NFAContext other) { return this.suffix(other); // || this.equals(other); }