Class: Rux::Lex::Transition
- Inherits:
-
Object
- Object
- Rux::Lex::Transition
- Defined in:
- lib/rux/lex/transition.rb
Instance Attribute Summary collapse
-
#advance_count ⇒ Object
readonly
Returns the value of attribute advance_count.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#to_state ⇒ Object
readonly
Returns the value of attribute to_state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, to_state, advance_count) ⇒ Transition
constructor
A new instance of Transition.
- #matches?(chr) ⇒ Boolean
Constructor Details
#initialize(input, to_state, advance_count) ⇒ Transition
Returns a new instance of Transition.
11 12 13 14 15 |
# File 'lib/rux/lex/transition.rb', line 11 def initialize(input, to_state, advance_count) @input = input @to_state = to_state @advance_count = advance_count end |
Instance Attribute Details
#advance_count ⇒ Object (readonly)
Returns the value of attribute advance_count.
4 5 6 |
# File 'lib/rux/lex/transition.rb', line 4 def advance_count @advance_count end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
4 5 6 |
# File 'lib/rux/lex/transition.rb', line 4 def input @input end |
#to_state ⇒ Object (readonly)
Returns the value of attribute to_state.
4 5 6 |
# File 'lib/rux/lex/transition.rb', line 4 def to_state @to_state end |
Class Method Details
.parse(str, input) ⇒ Object
6 7 8 9 |
# File 'lib/rux/lex/transition.rb', line 6 def self.parse(str, input) to_state, advance_count = str.match(/\A(\w+)\[?(-?\d+)?\]?/).captures new(input, :"tRUX_#{to_state.upcase}", (advance_count || 1).to_i) end |
Instance Method Details
#matches?(chr) ⇒ Boolean
17 18 19 |
# File 'lib/rux/lex/transition.rb', line 17 def matches?(chr) input.matches?(chr) end |