Transition classes override getSerializationType()

This commit is contained in:
Sam Harwell 2012-08-01 14:35:37 -05:00
parent 170a8347bb
commit 60df00be4f
10 changed files with 46 additions and 1 deletions

View File

@ -47,6 +47,11 @@ public class ActionTransition extends Transition {
this.isCtxDependent = isCtxDependent;
}
@Override
public int getSerializationType() {
return ACTION;
}
@Override
public boolean isEpsilon() {
return true; // we are to be ignored by analysis 'cept for predicates

View File

@ -42,6 +42,11 @@ public class AtomTransition extends Transition {
this.label = label;
}
@Override
public int getSerializationType() {
return ATOM;
}
@Override
@NotNull
public IntervalSet label() { return IntervalSet.of(label); }

View File

@ -34,6 +34,11 @@ import org.antlr.v4.runtime.misc.NotNull;
public class EpsilonTransition extends Transition {
public EpsilonTransition(@NotNull ATNState target) { super(target); }
@Override
public int getSerializationType() {
return EPSILON;
}
@Override
public boolean isEpsilon() { return true; }

View File

@ -38,6 +38,11 @@ public class NotSetTransition extends SetTransition {
super(target, set);
}
@Override
public int getSerializationType() {
return NOT_SET;
}
@Override
public String toString() {
return '~'+super.toString();

View File

@ -49,6 +49,11 @@ public class PredicateTransition extends Transition {
this.isCtxDependent = isCtxDependent;
}
@Override
public int getSerializationType() {
return PREDICATE;
}
@Override
public boolean isEpsilon() { return true; }

View File

@ -42,6 +42,11 @@ public class RangeTransition extends Transition {
this.to = to;
}
@Override
public int getSerializationType() {
return RANGE;
}
@Override
@NotNull
public IntervalSet label() { return IntervalSet.of(from, to); }

View File

@ -49,6 +49,11 @@ public class RuleTransition extends Transition {
this.followState = followState;
}
@Override
public int getSerializationType() {
return RULE;
}
@Override
public boolean isEpsilon() { return true; }
}

View File

@ -46,6 +46,11 @@ public class SetTransition extends Transition {
this.set = set;
}
@Override
public int getSerializationType() {
return SET;
}
@Override
@NotNull
public IntervalSet label() { return set; }

View File

@ -99,7 +99,7 @@ public abstract class Transition {
this.target = target;
}
public int getSerializationType() { return 0; }
public abstract int getSerializationType();
/** Are we epsilon, action, sempred? */
public boolean isEpsilon() { return false; }

View File

@ -34,6 +34,11 @@ import org.antlr.v4.runtime.misc.NotNull;
public class WildcardTransition extends Transition {
public WildcardTransition(@NotNull ATNState target) { super(target); }
@Override
public int getSerializationType() {
return WILDCARD;
}
@Override
@NotNull
public String toString() {