Class: RegularExpression::AST::Match
- Inherits:
-
Object
- Object
- RegularExpression::AST::Match
- Defined in:
- lib/regular_expression/ast.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
CharacterGroup | CharacterClass | Character | Period.
-
#quantifier ⇒ Object
readonly
Quantifier.
Instance Method Summary collapse
-
#initialize(item, quantifier: Quantifier::Once.new) ⇒ Match
constructor
A new instance of Match.
- #to_dot(parent) ⇒ Object
- #to_nfa(start, finish) ⇒ Object
Constructor Details
#initialize(item, quantifier: Quantifier::Once.new) ⇒ Match
Returns a new instance of Match.
98 99 100 101 |
# File 'lib/regular_expression/ast.rb', line 98 def initialize(item, quantifier: Quantifier::Once.new) @item = item @quantifier = quantifier end |
Instance Attribute Details
#item ⇒ Object (readonly)
CharacterGroup | CharacterClass | Character | Period
95 96 97 |
# File 'lib/regular_expression/ast.rb', line 95 def item @item end |
#quantifier ⇒ Object (readonly)
Quantifier
96 97 98 |
# File 'lib/regular_expression/ast.rb', line 96 def quantifier @quantifier end |
Instance Method Details
#to_dot(parent) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/regular_expression/ast.rb', line 103 def to_dot(parent) node = parent.add_node(object_id, label: "Match") item.to_dot(node) quantifier.to_dot(node) end |
#to_nfa(start, finish) ⇒ Object
110 111 112 113 114 |
# File 'lib/regular_expression/ast.rb', line 110 def to_nfa(start, finish) quantifier.quantify(start, finish) do |qstart, qfinish| item.to_nfa(qstart, qfinish) end end |