Skip to content

Commit

Permalink
Add support for zero-length reductions (means "grab them all"). 0-len…
Browse files Browse the repository at this point in the history
…gth reductions can only occur for the initial state (eg gramamr which matches the emty string and applied to garbage input)
  • Loading branch information
cgrand committed Aug 3, 2011
1 parent c2bfd02 commit 1c7b37e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/net/cgrand/parsley/fold.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
(.add (- N n)))
(.clear nodes)
(.clear offsets))
(zero? N)
(when tag
(let [children (vec (.toArray nodes))]
(doto nodes .clear (.add (make-node tag children)))
(doto offsets .clear (.add 0))))
:let [m (- n N)
offset (.get offsets m)
_ (-> offsets (.subList (inc m) n) .clear)]
Expand Down

0 comments on commit 1c7b37e

Please sign in to comment.