pinchot-0.20.0.0: Write grammars, not parsers

Safe HaskellNone
LanguageHaskell2010

Pinchot.Earley

Description

Creating Earley parsers.

Synopsis

Documentation

ruleToParser Source #

Arguments

:: Lift t 
=> String

Module prefix

-> Rule t 
-> [(Name, ExpQ)] 

Creates a list of pairs. Each list represents a statement in do notation. The first element of the pair is the name of the variable to which to bind the result of the expression, which is the second element of the pair.

branchToParser Source #

Arguments

:: Lift t 
=> String

Module prefix

-> Branch t 
-> ExpQ 

earleyGrammarFromRule Source #

Arguments

:: Lift t 
=> Qualifier

Module prefix holding the data types created with syntaxTrees

-> Rule t

Create a grammar for this Rule

-> Q Exp 

Creates an expression that has type

Grammar r (Prod r String (c, a) (p c a))

where r is left universally quantified; c is the terminal type (often Char), a is arbitrary metadata about each token (often Loc) and p is the data type corresponding to the given Rule.

Example: addressGrammar.

allRulesRecord Source #

Arguments

:: Qualifier

Qualifier for data types corresponding to those created from the Rules

-> Seq (Rule t)

A record is created that holds a value for each Rule in the Seq, as well as for every ancestor of these Rules.

-> DecsQ

When spliced, this will create a single declaration that is a record with the name Productions.

a'NAME

where NAME is the name of the type. Don't count on these records being in any particular order.

Creates a record data type that holds a value of type

Prod r String (t, a) (p t a)

where

  • r is left universally quantified
  • t is the token type (often Char)
  • a is any additional information about each token (often Loc)
  • p is the type of the particular production

This always creates a single product type whose name is Productions; currently the name cannot be configured.

Example: Pinchot.Examples.AllRulesRecord.

earleyProduct Source #

Arguments

:: Lift t 
=> Qualifier

Qualifier for data types corresponding to those created from the Rules

-> Qualifier

Qualifier for the type created with allRulesRecord

-> Seq (Rule t)

Creates an Earley grammar that contains a Prod for each Rule in this Seq, as well as all the ancestors of these Rules.

-> ExpQ

When spliced, earleyProduct creates an expression whose type is Grammar r (Productions r t a), where Productions is the type created by allRulesRecord; r is left universally quantified; t is the token type (often Char), and a is any additional information about each token (often Loc).

Creates a Grammar that contains a Prod for every given Rule and its ancestors. Example: addressAllProductions.