aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parcom/parser.cr5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/parcom/parser.cr b/src/parcom/parser.cr
index 95a2e21..d9919e1 100644
--- a/src/parcom/parser.cr
+++ b/src/parcom/parser.cr
@@ -102,7 +102,7 @@ module Parcom
end
end
- # Creates a parser from an array of `T` that tries to parser
+ # Creates a parser from an array of `T` that tries to parse
# each member of the array in sequence. An identical array is
# returned on success. If any of the tokens are absent, the
# whole parser fails.
@@ -112,6 +112,9 @@ module Parcom
Parser(T, T).sequence(ps).named("Token Sequence: #{ts}")
end
+ # Creates a parser from an array of parsers that tries each of
+ # them in sequence. It returns the result of the first successful
+ # parser and fails if none of the parsers succeed.
# TODO: Allow support for Iterable(Parser(T, U))
def self.first_of(ps : Array(Parser(T, U))) : Parser(T, U)
if ps.empty?