Class: RegularExpression::AST::CharacterRange
- Inherits:
-
Object
- Object
- RegularExpression::AST::CharacterRange
- Defined in:
- lib/regular_expression/ast.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
String.
-
#right ⇒ Object
readonly
String.
Instance Method Summary collapse
-
#initialize(left, right) ⇒ CharacterRange
constructor
A new instance of CharacterRange.
- #to_dot(parent) ⇒ Object
- #to_nfa(start, finish) ⇒ Object
- #to_nfa_values ⇒ Object
Constructor Details
#initialize(left, right) ⇒ CharacterRange
Returns a new instance of CharacterRange.
210 211 212 213 |
# File 'lib/regular_expression/ast.rb', line 210 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
String
208 209 210 |
# File 'lib/regular_expression/ast.rb', line 208 def left @left end |
#right ⇒ Object (readonly)
String
208 209 210 |
# File 'lib/regular_expression/ast.rb', line 208 def right @right end |
Instance Method Details
#to_dot(parent) ⇒ Object
215 216 217 |
# File 'lib/regular_expression/ast.rb', line 215 def to_dot(parent) parent.add_node(object_id, label: "#{left}-#{right}", shape: "box") end |
#to_nfa(start, finish) ⇒ Object
223 224 225 226 |
# File 'lib/regular_expression/ast.rb', line 223 def to_nfa(start, finish) transition = NFA::Transition::Range.new(finish, left, right) start.add_transition(transition) end |
#to_nfa_values ⇒ Object
219 220 221 |
# File 'lib/regular_expression/ast.rb', line 219 def to_nfa_values (left..right).to_a end |