Class: ABNF::Var
- Inherits:
-
Elt
show all
- Defined in:
- lib/abnf/abnf.rb,
lib/abnf/regexp.rb,
lib/abnf/grammar.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Elt
#*, #+, #empty_sequence?, #empty_set?, #remove_left_recursion, #remove_right_recursion, #rep, #|
Constructor Details
#initialize(name) ⇒ Var
Returns a new instance of Var.
149
150
151
|
# File 'lib/abnf/grammar.rb', line 149
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
152
153
154
|
# File 'lib/abnf/grammar.rb', line 152
def name
@name
end
|
Instance Method Details
#each_var {|@name| ... } ⇒ Object
154
|
# File 'lib/abnf/grammar.rb', line 154
def each_var(&block) yield @name end
|
#recursion(syms, lhs) ⇒ Object
#remove_just_recursion(n) ⇒ Object
364
365
366
367
368
369
370
|
# File 'lib/abnf/regexp.rb', line 364
def remove_just_recursion(n)
if n == self.name
EmptySet
else
self
end
end
|
#split_left_recursion(n) ⇒ Object
Also known as:
split_right_recursion
372
373
374
375
376
377
378
|
# File 'lib/abnf/regexp.rb', line 372
def split_left_recursion(n)
if n == self.name
[EmptySet, EmptySequence]
else
[self, EmptySet]
end
end
|
#split_recursion(n) ⇒ Object
#subst_var(&block) ⇒ Object
155
|
# File 'lib/abnf/grammar.rb', line 155
def subst_var(&block) yield(@name) || self end
|
#useful?(useful_names) ⇒ Boolean
123
|
# File 'lib/abnf/abnf.rb', line 123
def useful?(useful_names) useful_names[@name] end
|