From 7dba4925355cc57ef010914fa28e9cb653f477bb Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Fri, 24 Jan 2025 22:36:08 -0500 Subject: [PATCH] core: parseExactChar --- src/Parser/Interface.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Parser/Interface.md b/src/Parser/Interface.md index 4535ee0..f9bc23b 100644 --- a/src/Parser/Interface.md +++ b/src/Parser/Interface.md @@ -185,6 +185,19 @@ parseString' : Parser (List1 Char) -> Parser String parseString' x = parseString $ map forget x ``` +Attempt to parse a specified character + +```idris +export +parseExactChar : Char -> Parser Char +parseExactChar c = do + result <- parseChar (== c) id + case result of + GotChar char => pure char + GotError err => throwParseError "Got \{show err} Expected \{show c}" + EndOfInput => throwParseError "End of input" +``` + ### Composition of boolean functions ```idris