add fields and NFA/DFA

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6727]
This commit is contained in:
parrt 2010-02-24 13:41:22 -08:00
parent 6571ca437a
commit d5801b91d7
9 changed files with 47 additions and 28 deletions

View File

@ -0,0 +1,5 @@
package org.antlr.v4.automata;
/** */
public class BlockEndState extends NFAState {
}

View File

@ -1,5 +1,19 @@
package org.antlr.v4.automata;
import java.util.ArrayList;
import java.util.List;
/** */
public class BlockStartState extends NFAState {
public static final int INITIAL_NUM_TRANSITIONS = 4;
BlockEndState endState;
/** What's its decision number from 1..n? */
protected int decisionNumber = 0;
/** Track the transitions emanating from this NFA state. */
protected List<NFATransition> transitions =
new ArrayList<NFATransition>(INITIAL_NUM_TRANSITIONS);
}

View File

@ -1,5 +0,0 @@
package org.antlr.v4.automata;
/** */
public class BlockStopState extends NFAState {
}

View File

@ -0,0 +1,4 @@
package org.antlr.v4.automata;
public class DFA {
}

View File

@ -2,4 +2,8 @@ package org.antlr.v4.automata;
/** */
public class LoopbackState extends NFAState {
BlockStartState loopStartState;
/** What's its decision number from 1..n? */
protected int decisionNumber = 0;
}

View File

@ -0,0 +1,5 @@
package org.antlr.v4.automata;
/** */
public class NFA {
}

View File

@ -1,27 +1,14 @@
package org.antlr.v4.automata;
import org.antlr.analysis.Transition;
import java.util.ArrayList;
import java.util.List;
/**
* // I need to distinguish between NFA decision states for (...)* and (...)+
// during NFA interpretation.
public static final int LOOPBACK = 1;
public static final int BLOCK_START = 2;
public static final int OPTIONAL_BLOCK_START = 3;
public static final int BYPASS = 4;
public static final int RIGHT_EDGE_OF_BLOCK = 5;
make subclasses for all of these
*/
public class NFAState extends State {
public static final int INITIAL_NUM_TRANSITIONS = 4;
/** Which NFA are we in? */
public NFA nfa = null;
/** Track the transitions emanating from this NFA state. */
protected List<Transition> transitions =
new ArrayList<Transition>(INITIAL_NUM_TRANSITIONS);
/** For o-A->o type NFA tranitions, record the label that leads to this
* state. Useful for creating rich error messages when we find
* insufficiently (with preds) covered states.
*/
public NFATransition incidentTransition;
@Override
public int getNumberOfTransitions() {

View File

@ -2,4 +2,5 @@ package org.antlr.v4.automata;
/** */
public class RuleStartState extends NFAState {
RuleStopState stopState;
}

View File

@ -4,19 +4,23 @@ import org.antlr.v4.misc.IntSet;
import org.antlr.v4.misc.IntervalSet;
/** A label containing a set of values */
public class SetTransition extends Label {
public class SetTransition extends NFATransition {
/** A set of token types or character codes if label==SET */
protected IntSet label;
public SetTransition(IntSet label) {
if ( label==null ) {
this.label = IntervalSet.of(INVALID);
this.label = IntervalSet.of(Label.INVALID);
return;
}
this.label = label;
}
// public boolean intersect(Label other) {
public int compareTo(Object o) {
return 0;
}
// public boolean intersect(Label other) {
// if ( other.getClass() == SetTransition.class ) {
// return label.and(((SetTransition)other).label).isNil();
// }