Class: RLSM::RE::Concat
Overview
Instance Attribute Summary
Attributes inherited from SyntaxNode
#content
Instance Method Summary
collapse
Methods inherited from SyntaxNode
#<=>, [], #initialize, #inspect
Instance Method Details
#first ⇒ Object
399
400
401
402
403
404
405
406
407
|
# File 'lib/rlsm/regexp_parser.rb', line 399
def first
result = []
@content.each do |subexpr|
result << subexpr.first
break unless subexpr.null?
end
result.flatten.sort
end
|
#follow ⇒ Object
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
# File 'lib/rlsm/regexp_parser.rb', line 419
def follow
result = []
(@content.size-1).times do |i|
result |= @content[i].follow
@content[i].last.each do |char1|
@content[i+1].first.each do |char2|
result << [char1, char2]
end
end
end
result |= @content[-1].follow
result.sort
end
|
#last ⇒ Object
409
410
411
412
413
414
415
416
417
|
# File 'lib/rlsm/regexp_parser.rb', line 409
def last
result = []
@content.reverse.each do |subexpr|
result << subexpr.last
break unless subexpr.null?
end
result.flatten.sort
end
|
#null? ⇒ Boolean
395
396
397
|
# File 'lib/rlsm/regexp_parser.rb', line 395
def null?
@content.all? { |subexpr| subexpr.null? }
end
|
#to_s ⇒ Object
436
437
438
439
440
441
442
443
444
445
446
447
448
|
# File 'lib/rlsm/regexp_parser.rb', line 436
def to_s
string = ''
@content.each do |subexpr|
if Union === subexpr
string += "(#{subexpr.to_s})"
else
string += subexpr.to_s
end
end
string
end
|