Class: RLSM::RegExp::Concat

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

Instance Method Summary collapse

Constructor Details

#initialize(parent, str) ⇒ Concat

Returns a new instance of Concat.



403
404
405
406
407
408
# File 'lib/rlsm_regexp.rb', line 403

def initialize(parent, str)
  @parent = parent
  @childs = _split(str).map do |substr|
    NodeFactory.new_node(self, substr)
  end.reject { |child| child.lambda? }
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


472
473
474
# File 'lib/rlsm_regexp.rb', line 472

def empty?
  false
end

#firstObject



414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/rlsm_regexp.rb', line 414

def first
  res = []
  @childs.each do |child|
    child.first.each do |f|
      res << f
    end

    break unless child.null?
  end

  res
end

#followObject



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/rlsm_regexp.rb', line 440

def follow
  res = []

  @childs.each do |child|
    child.follow.each do |f|
      res << f
    end
  end

  (1...@childs.size).each do |i|
    @childs[i-1].last.each do |l|
      @childs[(i..-1)].each do |ch|
        ch.first.each do |f|
          res << [l,f]
        end

        break unless ch.null?
      end
    end
  end

  res
end

#lambda?Boolean

Returns:

  • (Boolean)


468
469
470
# File 'lib/rlsm_regexp.rb', line 468

def lambda?
  false
end

#lastObject



427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/rlsm_regexp.rb', line 427

def last
  res = []
  @childs.reverse.each do |child|
    child.last.each do |f|
      res << f
    end

    break unless child.null?
  end

  res
end

#null?Boolean

Returns:

  • (Boolean)


410
411
412
# File 'lib/rlsm_regexp.rb', line 410

def null?
  @childs.all? { |child| child.null? }
end

#to_sObject



464
465
466
# File 'lib/rlsm_regexp.rb', line 464

def to_s
  @childs.map { |child| child.to_s }.join
end