little-earley-0.2.0.0: Simple implementation of Earley parsing
Safe HaskellSafe-Inferred
LanguageHaskell2010

Little.Earley.Internal.Result

Synopsis

Documentation

data Result n t c Source #

Result of parse.

Constructors

ParseError (Error t c) 
ParseSuccess (ParsedResult n t c) 

Instances

Instances details
(PrettyPrint n, PrettyPrint t, PrettyPrint c) => PrettyPrint (Result n t c) Source # 
Instance details

Defined in Little.Earley.Internal.Result

Methods

prettyPrint :: Result n t c -> String Source #

data ParsedResult n t c Source #

Successful result of parse.

Constructors

ParsedResult 

Fields

data Error t c Source #

Parser error information.

Constructors

Error 

Fields

diagnoseError :: Ord t => Seq1 (Set (Item n t)) -> [c] -> Error t c Source #

lastNot :: (a -> Bool) -> Seq1 a -> (Int, a) Source #

nub_ :: Ord a => [a] -> [a] Source #

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:

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