Class: Hoozuki::Node::Literal

Inherits:
Object
  • Object
show all
Defined in:
lib/hoozuki/node/literal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Literal

Returns a new instance of Literal.



8
9
10
# File 'lib/hoozuki/node/literal.rb', line 8

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/hoozuki/node/literal.rb', line 6

def value
  @value
end

Instance Method Details

#to_nfa(state) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/hoozuki/node/literal.rb', line 12

def to_nfa(state)
  start_state = state.new_state
  accept_state = state.new_state
  nfa = Automaton::NFA.new(start_state, [accept_state])
  nfa.add_transition(start_state, @value, accept_state)
  nfa
end