Token parser

This commit is contained in:
Zoe Roux
2021-03-08 18:03:07 +01:00
parent 167e62c2bc
commit e60a824afc

View File

@@ -45,6 +45,9 @@ charIf f = do
x <- char
if f x then return x else empty
alphaNum :: Parser Char
alphaNum = charIf isAlphaNum
digit :: Parser Char
digit = charIf isDigit
@@ -67,6 +70,13 @@ maybeInt = P $ \str -> case parse int str of
Nothing -> Just (Nothing, str)
Just (y, lo) -> Just (Just y, lo)
token :: Parser a -> Parser a
token p = do
many $ charIf isSpace
ret <- p
many $ charIf isSpace
return ret
data Configuration = Configuration {
rule :: Int,
start :: Maybe Int,