Class: Hoozuki::Node::Repetition
- Inherits:
-
Object
- Object
- Hoozuki::Node::Repetition
- Defined in:
- lib/hoozuki/node/repetition.rb
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
Instance Method Summary collapse
-
#initialize(child, quantifier) ⇒ Repetition
constructor
A new instance of Repetition.
- #one_or_more? ⇒ Boolean
- #optional? ⇒ Boolean
- #to_nfa(state) ⇒ Object
- #zero_or_more? ⇒ Boolean
Constructor Details
#initialize(child, quantifier) ⇒ Repetition
Returns a new instance of Repetition.
8 9 10 11 |
# File 'lib/hoozuki/node/repetition.rb', line 8 def initialize(child, quantifier) @child = child @quantifier = quantifier end |
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
6 7 8 |
# File 'lib/hoozuki/node/repetition.rb', line 6 def child @child end |
Instance Method Details
#one_or_more? ⇒ Boolean
17 18 19 |
# File 'lib/hoozuki/node/repetition.rb', line 17 def one_or_more? @quantifier == :one_or_more end |
#optional? ⇒ Boolean
21 22 23 |
# File 'lib/hoozuki/node/repetition.rb', line 21 def optional? @quantifier == :optional end |
#to_nfa(state) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/hoozuki/node/repetition.rb', line 25 def to_nfa(state) if zero_or_more? to_nfa_zero_or_more(state) elsif one_or_more? to_nfa_one_or_more(state) elsif optional? to_nfa_optional(state) end end |
#zero_or_more? ⇒ Boolean
13 14 15 |
# File 'lib/hoozuki/node/repetition.rb', line 13 def zero_or_more? @quantifier == :zero_or_more end |