Class: ABNF::Elt
- Inherits:
-
Object
- Object
- ABNF::Elt
- Defined in:
- lib/abnf/regexp.rb,
lib/abnf/grammar.rb
Instance Method Summary collapse
- #*(n) ⇒ Object
- #+(other) ⇒ Object
-
#empty_sequence? ⇒ Boolean
A variable is assumed as not empty sequence.
-
#empty_set? ⇒ Boolean
A variable is assumed as not empty set.
- #remove_left_recursion(n) ⇒ Object
- #remove_right_recursion(n) ⇒ Object
- #rep(min = 0, max = nil, greedy = true) ⇒ Object
- #|(other) ⇒ Object
Instance Method Details
#*(n) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/abnf/grammar.rb', line 23 def *(n) case n when Integer rep(n, n) when Range rep(n.first, n.last - (n.exclude_end? ? 1 : 0)) else raise TypeError.new("Integer or Range expected: #{n}") end end |
#+(other) ⇒ Object
15 16 17 |
# File 'lib/abnf/grammar.rb', line 15 def +(other) Seq.new(self, other) end |
#empty_sequence? ⇒ Boolean
A variable is assumed as not empty sequence.
11 12 13 |
# File 'lib/abnf/grammar.rb', line 11 def empty_sequence? false end |
#empty_set? ⇒ Boolean
A variable is assumed as not empty set.
6 7 8 |
# File 'lib/abnf/grammar.rb', line 6 def empty_set? false end |
#remove_left_recursion(n) ⇒ Object
168 169 170 171 |
# File 'lib/abnf/regexp.rb', line 168 def remove_left_recursion(n) nonrec, rest = split_left_recursion(n) Seq.new(nonrec, rest.rep) end |
#remove_right_recursion(n) ⇒ Object
173 174 175 176 |
# File 'lib/abnf/regexp.rb', line 173 def remove_right_recursion(n) nonrec, rest = split_right_recursion(n) Seq.new(rest.rep, nonrec) end |