1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
8 #include "misc/IntervalSet.h"
14 /// An ATN transition between any two ATN states. Subclasses define
15 /// atom, set, epsilon, action, predicate, rule transitions.
17 /// This is a one way link. It emanates from a state (usually via a list of
18 /// transitions) and has a target state.
20 /// Since we never have to change the ATN transitions once we construct it,
21 /// we can fix these transitions as specific classes. The DFA transitions
22 /// on the other hand need to update the labels as it adds transitions to
23 /// the states. We'll use the term Edge for the DFA to distinguish them from
26 class ANTLR4CPP_PUBLIC Transition {
28 // constants for serialization
29 enum SerializationType {
33 PREDICATE = 4, // e.g., {isType(input.LT(1))}?
36 SET = 7, // ~(A|B) or ~atom, wildcard, which convert to next 2
42 static const std::vector<std::string> serializationNames;
44 /// The target of this transition.
45 // ml: this is a reference into the ATN.
48 virtual ~Transition();
51 Transition(ATNState *target);
54 virtual SerializationType getSerializationType() const = 0;
57 * Determines if the transition is an "epsilon" transition.
59 * <p>The default implementation returns {@code false}.</p>
61 * @return {@code true} if traversing this transition in the ATN does not
62 * consume an input symbol; otherwise, {@code false} if traversing this
63 * transition consumes (matches) an input symbol.
65 virtual bool isEpsilon() const;
66 virtual misc::IntervalSet label() const;
67 virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const = 0;
69 virtual std::string toString() const;
71 Transition(Transition const&) = delete;
72 Transition& operator=(Transition const&) = delete;