1 /* 2 * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 * Use of this file is governed by the BSD 3-clause license that 4 * can be found in the LICENSE.txt file in the project root. 5 */ 6 7 module antlr.v4.runtime.atn.Transition; 8 9 import std.conv; 10 import antlr.v4.runtime.atn.TransitionStates; 11 import antlr.v4.runtime.atn.EpsilonTransition; 12 import antlr.v4.runtime.atn.RuleTransition; 13 import antlr.v4.runtime.atn.PredicateTransition; 14 import antlr.v4.runtime.atn.RangeTransition; 15 import antlr.v4.runtime.atn.AtomTransition; 16 import antlr.v4.runtime.atn.ActionTransition; 17 import antlr.v4.runtime.atn.SetTransition; 18 import antlr.v4.runtime.atn.NotSetTransition; 19 import antlr.v4.runtime.atn.WildcardTransition; 20 import antlr.v4.runtime.atn.PrecedencePredicateTransition; 21 import antlr.v4.runtime.atn.ATNState; 22 import antlr.v4.runtime.misc.IntervalSet; 23 24 /** 25 * An ATN transition between any two ATN states. Subclasses define 26 * atom, set, epsilon, action, predicate, rule transitions. 27 * 28 * <p>This is a one way link. It emanates from a state (usually via a list of 29 * transitions) and has a target state.</p> 30 * 31 * <p>Since we never have to change the ATN transitions once we construct it, 32 * we can fix these transitions as specific classes. The DFA transitions 33 * on the other hand need to update the labels as it adds transitions to 34 * the states. We'll use the term Edge for the DFA to distinguish them from 35 * ATN transitions.</p> 36 */ 37 abstract class Transition 38 { 39 40 /** 41 * The target of this transition. 42 */ 43 public ATNState target; 44 45 public static string[] serializationNames = [ 46 "INVALID", 47 "EPSILON", 48 "RANGE", 49 "RULE", 50 "PREDICATE", 51 "ATOM", 52 "ACTION", 53 "SET", 54 "NOT_SET", 55 "WILDCARD", 56 "PRECEDENCE" 57 ]; 58 59 public this(ATNState target) 60 { 61 this.target = target; 62 } 63 64 public this() 65 { 66 } 67 68 abstract public int getSerializationType(); 69 70 /** 71 * Determines if the transition is an "epsilon" transition. 72 * 73 * <p>The default implementation returns {@code false}.</p> 74 * 75 * @return {@code true} if traversing this transition in the ATN does not 76 * consume an input symbol; otherwise, {@code false} if traversing this 77 * transition consumes (matches) an input symbol. 78 */ 79 public bool isEpsilon() 80 { 81 return false; 82 } 83 84 public IntervalSet label() 85 { 86 return null; 87 } 88 89 abstract public bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol); 90 91 }