Permalink
Browse files

! rewritten part of it as ruby18

  • Loading branch information...
1 parent 92c5ee0 commit 159edfddc9e3b0feff59da92c260c2cd2598e625 @kschiess committed Sep 17, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/parslet/atoms/sequence.rb
@@ -20,16 +20,22 @@ def >>(parslet)
end
def try(source, context, consume_all)
- succ([:sequence]+parslets.map.each_with_index { |p, idx|
+ # Presize an array
+ result = Array.new(parslets.size + 1)
+ result[0] = :sequence
+
+ parslets.each_with_index do |p, idx|
child_consume_all = consume_all && (idx == parslets.size-1)
success, value = p.apply(source, context, child_consume_all)
unless success
return context.err(self, source, @error_msgs[:failed], [value])
end
- value
- })
+ result[idx+1] = value
+ end
+
+ return succ(result)
end
precedence SEQUENCE

0 comments on commit 159edfd

Please sign in to comment.