Class: Antlr4::Runtime::RangeTransition

Inherits:
Transition
  • Object
show all
Defined in:
lib/antlr4/runtime/range_transition.rb

Constant Summary

Constants inherited from Transition

Transition::ACTION, Transition::ATOM, Transition::EPSILON, Transition::NOT_SET, Transition::PRECEDENCE, Transition::PREDICATE, Transition::RANGE, Transition::RULE, Transition::SET, Transition::WILDCARD

Instance Attribute Summary collapse

Attributes inherited from Transition

#target

Instance Method Summary collapse

Methods inherited from Transition

#epsilon?

Constructor Details

#initialize(target, from, to) ⇒ RangeTransition

Returns a new instance of RangeTransition


7
8
9
10
11
# File 'lib/antlr4/runtime/range_transition.rb', line 7

def initialize(target, from, to)
  super(target)
  @from = from
  @to = to
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from


4
5
6
# File 'lib/antlr4/runtime/range_transition.rb', line 4

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to


5
6
7
# File 'lib/antlr4/runtime/range_transition.rb', line 5

def to
  @to
end

Instance Method Details

#labelObject


17
18
19
# File 'lib/antlr4/runtime/range_transition.rb', line 17

def label
  IntervalSet.of(@from, @to)
end

#matches(symbol, _min_vocab_symbol, _max_vocab_symbol) ⇒ Object


21
22
23
# File 'lib/antlr4/runtime/range_transition.rb', line 21

def matches(symbol, _min_vocab_symbol, _max_vocab_symbol)
  symbol >= @from && symbol <= @to
end

#serialization_typeObject


13
14
15
# File 'lib/antlr4/runtime/range_transition.rb', line 13

def serialization_type
  RANGE
end

#to_sObject


25
26
27
# File 'lib/antlr4/runtime/range_transition.rb', line 25

def to_s
  "'" << @from << "'..'" << @to << "'"
end