Class: RBNF::Alt

Inherits:
Binary show all
Defined in:
lib/rbnf/nodes.rb

Overview

Alternation node

Constant Summary

Constants included from RBNF

DEFS, VERSION

Instance Attribute Summary

Attributes inherited from Binary

#a, #b

Instance Method Summary collapse

Methods included from RBNF

#=~, [], #alt, #cat, #comps, def, define, dememoize, #except, #group, method_missing, #opt, #rep, #rep_n

Constructor Details

#initialize(a, b) ⇒ Alt

Returns a new instance of Alt.



26
27
28
29
# File 'lib/rbnf/nodes.rb', line 26

def initialize(a,b)
  @memo={}
  @a,@b=[a,b].map {|e| Cat===e ? e.group : e}
end

Instance Method Details

#match(s) ⇒ Object



30
31
32
# File 'lib/rbnf/nodes.rb', line 30

def match(s)
  a=~s or b=~s
end

#to_sObject



23
24
25
# File 'lib/rbnf/nodes.rb', line 23

def to_s
  "#{a} | #{b}"
end