Class: RLSM::RegExp::Concat
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #first ⇒ Object
- #follow ⇒ Object
-
#initialize(parent, str) ⇒ Concat
constructor
A new instance of Concat.
- #lambda? ⇒ Boolean
- #last ⇒ Object
- #null? ⇒ Boolean
- #to_s ⇒ Object
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
472 473 474 |
# File 'lib/rlsm_regexp.rb', line 472 def empty? false end |
#first ⇒ Object
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 |
#follow ⇒ Object
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
468 469 470 |
# File 'lib/rlsm_regexp.rb', line 468 def lambda? false end |
#last ⇒ Object
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
410 411 412 |
# File 'lib/rlsm_regexp.rb', line 410 def null? @childs.all? { |child| child.null? } end |
#to_s ⇒ Object
464 465 466 |
# File 'lib/rlsm_regexp.rb', line 464 def to_s @childs.map { |child| child.to_s }.join end |