Class: Kleene::NFATransition

Inherits:
Object
  • Object
show all
Defined in:
lib/kleene/nfa.rb

Constant Summary collapse

Epsilon =

todo/hack: we use the null character as a sentinal character indicating epsilon transition

"\u0000"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, from_state, to_state) ⇒ NFATransition

Returns a new instance of NFATransition.



9
10
11
12
13
# File 'lib/kleene/nfa.rb', line 9

def initialize(token, from_state, to_state)
  @token = token
  @from = from_state
  @to = to_state
end

Instance Attribute Details

#fromObject

: State



6
7
8
# File 'lib/kleene/nfa.rb', line 6

def from
  @from
end

#toObject

: State



7
8
9
# File 'lib/kleene/nfa.rb', line 7

def to
  @to
end

#tokenObject

: Char



5
6
7
# File 'lib/kleene/nfa.rb', line 5

def token
  @token
end

Instance Method Details

#accept?(input) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/kleene/nfa.rb', line 15

def accept?(input)
  @token == input
end

#epsilon?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/kleene/nfa.rb', line 19

def epsilon?
  token == Epsilon
end