Class: RegularExpression::AST::CharacterRange

Inherits:
Object
  • Object
show all
Defined in:
lib/regular_expression/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ CharacterRange

Returns a new instance of CharacterRange.



210
211
212
213
# File 'lib/regular_expression/ast.rb', line 210

def initialize(left, right)
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject (readonly)

String



208
209
210
# File 'lib/regular_expression/ast.rb', line 208

def left
  @left
end

#rightObject (readonly)

String



208
209
210
# File 'lib/regular_expression/ast.rb', line 208

def right
  @right
end

Instance Method Details

#to_dot(parent) ⇒ Object



215
216
217
# File 'lib/regular_expression/ast.rb', line 215

def to_dot(parent)
  parent.add_node(object_id, label: "#{left}-#{right}", shape: "box")
end

#to_nfa(start, finish) ⇒ Object



223
224
225
226
# File 'lib/regular_expression/ast.rb', line 223

def to_nfa(start, finish)
  transition = NFA::Transition::Range.new(finish, left, right)
  start.add_transition(transition)
end

#to_nfa_valuesObject



219
220
221
# File 'lib/regular_expression/ast.rb', line 219

def to_nfa_values
  (left..right).to_a
end