lib/raabro.rb in raabro-1.0.2 vs lib/raabro.rb in raabro-1.0.3
- old
+ new
@@ -24,11 +24,11 @@
#++
module Raabro
- VERSION = '1.0.2'
+ VERSION = '1.0.3'
class Input
attr_accessor :string, :offset
attr_reader :options
@@ -79,21 +79,10 @@
def prune!
@children = successful_children
end
- def shrink!
-
- @children =
- @children.inject([]) do |a, c|
- a << c.shrink! if c.result == 1 && c.name
- a
- end
-
- self
- end
-
def string
@input.string[@offset, @length]
end
@@ -399,10 +388,12 @@
end
alias jseq eseq
def parse(input, opts={})
+ opts[:prune] = true unless opts.has_key?(:prune)
+
root = self.respond_to?(:root) ? :root : @last
t =
if opts[:all] == false
_parse(root, Raabro::Input.new(input, opts))
@@ -411,10 +402,9 @@
end
return nil if opts[:prune] != false && t.result != 1
t = t.children.first if t.parter == :all
- t = (opts[:prune] == false) || (opts[:shrink] == false) ? t : t.shrink!
return rewrite(t) if opts[:rewrite] != false && respond_to?(:rewrite)
t
end