Class: RLSM::RegExp::NodeFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rlsm_regexp.rb

Class Method Summary collapse

Class Method Details

.new_node(parent, arg) ⇒ Object



513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/rlsm_regexp.rb', line 513

def self.new_node(parent, arg)

  #Remove parentheses
  str = arg.dup
  while sp(str)
    str = str[(1..-2)]
  end
#puts "Processing: #{arg} from #{parent.class}"
  #Choose the right node type
  if prim?(str)
    return PrimExp.new(parent, str)
  elsif star?(str)
    return Star.new(parent, str)
  elsif union?(str)
    return Union.new(parent, str)
  else
    return Concat.new(parent, str)
  end

end