lib/raabro.rb in raabro-1.0.4 vs lib/raabro.rb in raabro-1.0.5
- old
+ new
@@ -24,11 +24,11 @@
#++
module Raabro
- VERSION = '1.0.4'
+ VERSION = '1.0.5'
class Input
attr_accessor :string, :offset
attr_reader :options
@@ -172,19 +172,13 @@
end
end
def _narrow(parser)
- raise ArgumentError.new("lone quantifier #{parser}") if _quantify(parser)
+ fail ArgumentError.new("lone quantifier #{parser}") if _quantify(parser)
- return parser if parser.is_a?(Method)
- return method(parser) if parser.is_a?(Symbol)
-
- k, m = parser.to_s.split('.')
- k, m = [ Object, k ] unless m
-
- Kernel.const_get(k).method(m)
+ method(parser.to_sym)
end
def _parse(parser, input)
_narrow(parser).call(input)
@@ -398,9 +392,14 @@
@last = name.to_sym
end
def parse(input, opts={})
+
+ d = opts[:debug].to_i
+ opts[:rewrite] = false if d > 0
+ opts[:all] = false if d > 1
+ opts[:prune] = false if d > 2
opts[:prune] = true unless opts.has_key?(:prune)
root = self.respond_to?(:root) ? :root : @last