aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-03-19 22:18:45 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-03-19 22:18:45 +1300
commit2ef8841e9c7a48eea0f66cfe09d8fe996f43c2b2 (patch)
tree78f4e670b066c41d2552db2fa598bb0aa185ea0c
parent54263a0cfec5ef1adcd1bf6541abc0275d9a98df (diff)
Documentation
-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?