Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

. comments

  • Loading branch information...
1 parent cbb8da9 commit 03564fb98eef666f327e389d988de697182ce2b5 @kschiess committed
Showing with 6 additions and 0 deletions.
  1. +6 −0 experiments/local.rb
6 experiments/local.rb
@@ -30,7 +30,13 @@ def to_s_inner(prec) # :nodoc:
def this(&block); return end
def epsilon; any.absnt? end
+# Traditional repetition will try as long as the pattern can be matched and
+# then give up. This is greedy and blind.
a = str('a').as(:e) >> this { a }.as(:rec) | epsilon
+# Here's a pattern match that is greedy and non-blind. The first pattern
+# 'a'* will be tried as many times as possible, while still matching the
+# end pattern 'aa'.
b = str('aa').as(:e2) >> epsilon | str('a').as(:e1) >> this { b }.as(:rec)
p a.parse('aaaa')

0 comments on commit 03564fb

Please sign in to comment.
Something went wrong with that request. Please try again.