Portability | portable |
---|---|
Stability | experimental |
Maintainer | tanaka.hideyuki@gmail.com |
The monadic parser type and combinators to construct packrat parsers for code generator.
- parse :: MemoTable tbl => (forall s. Parser tbl str s a) -> SrcPos -> str -> Either ParseError a
- parseString :: MemoTable tbl => (forall s. Parser tbl str s a) -> String -> str -> Either ParseError a
- parseFile :: MemoTable tbl => (forall s. Parser tbl String s a) -> FilePath -> IO (Either ParseError a)
- newtype Parser tbl str s a = Parser {}
- data Result str a
- = Parsed SrcPos Char str a
- | Failed ParseError
- data ParseError = ParseError SrcLoc String
- class MemoTable tbl where
- memo :: (tbl s -> HashTable s Int (Result str a)) -> Parser tbl str s a -> Parser tbl str s a
- getPos :: Parser tbl str s SrcPos
- setPos :: SrcPos -> Parser tbl str s ()
- anyChar :: ListLike str Char => Parser tbl str s Char
- satisfy :: ListLike str Char => (Char -> Bool) -> Parser tbl str s Char
- char :: ListLike str Char => Char -> Parser tbl str s Char
- string :: ListLike str Char => String -> Parser tbl str s String
- expect :: ListLike str Char => Parser tbl str s a -> Parser tbl str s ()
- unexpect :: ListLike str Char => Parser tbl str s a -> Parser tbl str s ()
- space :: ListLike str Char => Parser tbl str s ()
- defaultDelimiter :: ListLike str Char => Parser tbl str s ()
- token :: ListLike str Char => Parser tbl str s () -> Parser tbl str s () -> Parser tbl str s a -> Parser tbl str s a
Parsing functions
:: MemoTable tbl | |
=> (forall s. Parser tbl str s a) | parser |
-> SrcPos | input information |
-> str | input string |
-> Either ParseError a | result |
Parsing function
:: MemoTable tbl | |
=> (forall s. Parser tbl str s a) | parser |
-> String | input name |
-> str | input string |
-> Either ParseError a | result |
Parsing function with only input name
:: MemoTable tbl | |
=> (forall s. Parser tbl String s a) | parser |
-> FilePath | input filename |
-> IO (Either ParseError a) | result |
Parse from file
The parser type
newtype Parser tbl str s a
MonadError ParseError (Parser tbl str s) | |
Monad (Parser tbl str s) | |
Functor (Parser tbl str s) | |
Applicative (Parser tbl str s) | |
Alternative (Parser tbl str s) |
The (internal) result type
The error type
data ParseError
Show ParseError | |
Error ParseError | |
MonadError ParseError (Parser tbl str s) |
The cache type
Memoising combinator
Position functions
Combinators
Utiligy
defaultDelimiter :: ListLike str Char => Parser tbl str s ()