Class: Transition

Inherits:
Object show all
Defined in:
lib/antlr4/atn/Transition.rb

Overview

An ATN transition between any two ATN states. Subclasses define

atom, set, epsilon, action, predicate, rule transitions.

<p>This is a one way link.  It emanates from a state (usually via a list of
transitions) and has a target state.</p>

<p>Since we never have to change the ATN transitions once we construct it,
we can fix these transitions as specific classes. The DFA transitions
on the other hand need to update the labels as it adds transitions to
the states. We'll use the term Edge for the DFA to distinguish them from
ATN transitions.</p>

Constant Summary collapse

EPSILON =

constants for serialization

1
RANGE =
2
RULE =
3
PREDICATE =

e.g., Transition.isType(inputisType(input.LT(1))?

4
ATOM =
5
ACTION =
6
SET =

~(A|B) or ~atom, wildcard, which convert to next 2

7
NOT_SET =
8
WILDCARD =
9
PRECEDENCE =
10
@@serializationNames =
[
    "INVALID",
    "EPSILON",
    "RANGE",
    "RULE",
    "PREDICATE",
    "ATOM",
    "ACTION",
    "SET",
    "NOT_SET",
    "WILDCARD",
    "PRECEDENCE"
]
@@serializationTypes =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Transition

Returns a new instance of Transition.

Raises:

  • (Exception)


52
53
54
55
56
57
58
59
# File 'lib/antlr4/atn/Transition.rb', line 52

def initialize(target)
    # The target of this transition.
    raise Exception.new("target cannot be null.") if target.nil?
    self.target = target
    # Are we epsilon, action, sempred?
    self.isEpsilon = false
    @ruleIndex = 0
end

Instance Attribute Details

#isEpsilonObject

Returns the value of attribute isEpsilon.



51
52
53
# File 'lib/antlr4/atn/Transition.rb', line 51

def isEpsilon
  @isEpsilon
end

#ruleIndexObject

Returns the value of attribute ruleIndex.



51
52
53
# File 'lib/antlr4/atn/Transition.rb', line 51

def ruleIndex
  @ruleIndex
end

#serializationTypeObject

Returns the value of attribute serializationType.



51
52
53
# File 'lib/antlr4/atn/Transition.rb', line 51

def serializationType
  @serializationType
end

#targetObject

Returns the value of attribute target.



51
52
53
# File 'lib/antlr4/atn/Transition.rb', line 51

def target
  @target
end

Class Method Details

.serializationNamesObject



39
40
41
# File 'lib/antlr4/atn/Transition.rb', line 39

def self.serializationNames 
  @@serializationNames 
end

.serializationTypesObject



44
45
46
# File 'lib/antlr4/atn/Transition.rb', line 44

def self.serializationTypes 
  @@serializationTypes 
end

.serializationTypes=(newhash) ⇒ Object



47
48
49
# File 'lib/antlr4/atn/Transition.rb', line 47

def self.serializationTypes=(newhash)
    @@serializationTypes = newhash
end

Instance Method Details

#labelObject



60
61
62
# File 'lib/antlr4/atn/Transition.rb', line 60

def label
    nil
end