From 38c69c0ae391194cbdaca9868dac2d15d6e040ff Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Fri, 24 Jan 2025 23:57:16 -0500 Subject: [PATCH] core: parseTheseChars --- src/Parser/Interface.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Parser/Interface.md b/src/Parser/Interface.md index f9bc23b..fe13c13 100644 --- a/src/Parser/Interface.md +++ b/src/Parser/Interface.md @@ -198,6 +198,19 @@ parseExactChar c = do EndOfInput => throwParseError "End of input" ``` +Attempt to parse one of a list of chars + +```idris +export +parseTheseChars : List Char -> Parser Char +parseTheseChars cs = do + result <- parseChar (\x => any (== x) cs) id + case result of + GotChar char => pure char + GotError err => throwParseError "Got \{show err} Expected one of \{show cs}" + EndOfInput => throwParseError "End of input" +``` + ### Composition of boolean functions ```idris