1 /*
2  * Copyright (c) 2012-2020 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.EpsilonTransition;
8 
9 import antlr.v4.runtime.atn.ATNState;
10 import antlr.v4.runtime.atn.Transition;
11 import antlr.v4.runtime.atn.TransitionStates;
12 
13 /**
14  * Special Transition
15  */
16 class EpsilonTransition : Transition
17 {
18 
19     /**
20      *  @return the rule index of a precedence rule for which this transition is
21      *  returning from, where the precedence value is 0; otherwise, -1.
22      *
23      *  @see ATNConfig#isPrecedenceFilterSuppressed()
24      *  @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet)
25      *  @since 4.4.1
26      * @uml
27      * @read
28      * @final
29      */
30     private int outermostPrecedenceReturn_;
31 
32     public this(ATNState target)
33     {
34         this(target, -1);
35     }
36 
37     public this(ATNState target, int outermostPrecedenceReturn)
38     {
39         super(target);
40         this.outermostPrecedenceReturn_ = outermostPrecedenceReturn;
41     }
42 
43     /**
44      * Only for unittest required.
45      */
46     public this()
47     {
48     }
49 
50     /**
51      * @uml
52      * @override
53      */
54     public override int getSerializationType()
55     {
56         return TransitionStates.EPSILON;
57     }
58 
59     /**
60      * @uml
61      * @override
62      */
63     public override bool isEpsilon()
64     {
65         return true;
66     }
67 
68     /**
69      * @uml
70      * @override
71      */
72     public override bool matches(int symbol, int minVocabSymbol, int maxVocabSymbol)
73     {
74         return false;
75     }
76 
77     /**
78      * @uml
79      * @override
80      */
81     public override string toString()
82     {
83         return "epsilon";
84     }
85 
86     public final int outermostPrecedenceReturn()
87     {
88         return this.outermostPrecedenceReturn_;
89     }
90 
91 }