Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Result n t c
- = ParseError (Error t c)
- | ParseSuccess (ParsedResult n t c)
- data ParsedResult n t c = ParsedResult {
- prParseTree :: TreeSet n t c
- prAmbiguities :: [LocAmbiguity n t c]
- data Error t c = Error {
- errorPosition :: Int
- errorToken :: Maybe c
- errorExpected :: [t]
- errorInput :: [c]
- diagnoseError :: Ord t => Seq1 (Set (Item n t)) -> [c] -> Error t c
- lastNot :: (a -> Bool) -> Seq1 a -> (Int, a)
- nub_ :: Ord a => [a] -> [a]
- parse :: (Ord n, Ord t) => Grammar n t c -> n -> [c] -> Result n t c
- pparse :: (Ord n, Ord t) => Grammar n t c -> n -> [c] -> Pretty (Result n t c)
Documentation
Result of parse
.
ParseError (Error t c) | |
ParseSuccess (ParsedResult n t c) |
Instances
(PrettyPrint n, PrettyPrint t, PrettyPrint c) => PrettyPrint (Result n t c) Source # | |
Defined in Little.Earley.Internal.Result prettyPrint :: Result n t c -> String Source # |
data ParsedResult n t c Source #
Successful result of parse
.
ParsedResult | |
|
Parser error information.
Error | |
|
parse :: (Ord n, Ord t) => Grammar n t c -> n -> [c] -> Result n t c Source #
Parse a chain of tokens [c]
given a grammar and a starting symbol n
.
Variants:
pparse
: pretty-printed; use this in the REPL.parseTreeSet
: outputs just the parse tree.accepts
: outputs a mere boolean.
Example
parse
arithG SUM "1+2*3"
pparse :: (Ord n, Ord t) => Grammar n t c -> n -> [c] -> Pretty (Result n t c) Source #
Wrapped parse
with a pretty-printed result. Use this in the REPL.
Example
pparse
arithG SUM "1+2*3"
Output:
+-----+--SUM #1---+ | | | SUM #0 | +PRODUCT #1-+ | | | | | PRODUCT #0 | PRODUCT #0 | | | | | | | FACTOR #0 | FACTOR #0 | FACTOR #0 | | | | | NUMBER #0 | NUMBER #0 | NUMBER #0 | | | | | ----------------------------------- 1 + 2 * 3