aboutsummaryrefslogtreecommitdiff
path: root/src/parcom.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/parcom.cr')
-rw-r--r--src/parcom.cr12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/parcom.cr b/src/parcom.cr
index dbdd44d..3aed672 100644
--- a/src/parcom.cr
+++ b/src/parcom.cr
@@ -67,9 +67,12 @@ module Parcom
Plus.new(self, other)
end
- # TODO: allow/change to support block invocation
def assert(f : V -> Bool)
- Assert.new(self, f)
+ Assert.new(self, &f)
+ end
+
+ def assert(&block : V -> Bool)
+ Assert.new(self, &block)
end
# TODO: allow/change to support block invocation
@@ -118,9 +121,9 @@ module Parcom
end
end
- # TODO: allow/change to support block invocation
class Assert(T, V) < Parser(T, V)
- def initialize(@p : Parser(T, V), @f : V -> Bool)
+ def initialize(@p : Parser(T, V), &block : V -> Bool)
+ @f = block
end
def parse(tokens : TokenStream(T)) : Result(T, V)
@@ -212,7 +215,6 @@ module Parcom
end
end
- # TODO: find a way to make this use Recover on the back end
class Optional(T, V) < Parser(T, V?)
def initialize(@p : Parser(T, V))
end