Restructuring, #9
This commit is contained in:
parent
2055ef234e
commit
dab6fadad4
41 changed files with 941 additions and 680 deletions
|
@ -1,7 +1,23 @@
|
|||
module RPGEngine.Parse.Core where
|
||||
module RPGEngine.Parse.Core
|
||||
( parseWith
|
||||
, parseWithRest
|
||||
, ignoreWS
|
||||
) where
|
||||
|
||||
import Text.Parsec
|
||||
import Text.Parsec.String
|
||||
( ParseError,
|
||||
anyChar,
|
||||
endOfLine,
|
||||
spaces,
|
||||
string,
|
||||
anyToken,
|
||||
choice,
|
||||
eof,
|
||||
manyTill,
|
||||
parse )
|
||||
import Text.Parsec.String ( Parser )
|
||||
|
||||
------------------------------ Exported ------------------------------
|
||||
|
||||
-- A wrapper, which takes a parser and some input and returns a
|
||||
-- parsed output.
|
||||
|
@ -14,7 +30,7 @@ parseWithRest :: Parser a -> String -> Either ParseError (a, String)
|
|||
parseWithRest parser = parse ((,) <$> parser <*> rest) ""
|
||||
where rest = manyTill anyToken eof
|
||||
|
||||
-- Ignore all kinds of whitespaces
|
||||
-- Ignore all kinds of whitespace
|
||||
ignoreWS :: Parser a -> Parser a
|
||||
ignoreWS parser = choice [skipComment, spaces] >> parser
|
||||
where skipComment = do{ string "#"; manyTill anyChar endOfLine; return ()}
|
Reference in a new issue