class RegularExpression::AST::Root
Attributes
at_start[R]
expressions[R]
Public Class Methods
new(expressions, at_start: false)
click to toggle source
# File lib/regular_expression/ast.rb, line 17 def initialize(expressions, at_start: false) @expressions = expressions @at_start = at_start end
Public Instance Methods
to_dot(graph)
click to toggle source
# File lib/regular_expression/ast.rb, line 22 def to_dot(graph) label = "Root" label = "#{label} (at start)" if at_start node = graph.add_node(object_id, label: label) expressions.each { |expression| expression.to_dot(node) } end
to_nfa()
click to toggle source
# File lib/regular_expression/ast.rb, line 30 def to_nfa start = NFA::StartState.new current = start if at_start current = NFA::State.new start.add_transition(NFA::Transition::BeginAnchor.new(current)) end finish = NFA::FinishState.new expressions.each do |expression| expression.to_nfa(current, finish) end start end