parsley-1.0.0.2: A fast parser combinator library backed by Typed Template Haskell
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Parsley.Precedence

Description

This module exposes the required machinery for parsing expressions given by a precedence table. Unlike those found in parser-combinators or parsec, this implementation allows the precedence layers to change type in the table.

Since: 0.1.0.0

Synopsis

Documentation

class Monolith a b c where Source #

This class provides a way of working with the Level datatype without needing to provide wrappers, or not providing Defunc arguments.

Since: 0.1.0.0

Methods

infixL :: [Parser (b -> a -> b)] -> c Source #

Used to construct a precedence level of infix left-associative operators

infixR :: [Parser (a -> b -> b)] -> c Source #

Used to construct a precedence level of infix right-associative operators

prefix :: [Parser (b -> b)] -> c Source #

Used to construct a precedence level of prefix operators

postfix :: [Parser (b -> b)] -> c Source #

Used to construct a precedence level of postfix operators

Instances

Instances details
x ~ (WQ (a -> b) -> Level a b) => Monolith a b x Source #

This instance is used to handle non-monolithic types: i.e. where the input and output types of a level differ.

Since: 0.1.0.0

Instance details

Defined in Parsley.Precedence

Methods

infixL :: [Parser (b -> a -> b)] -> x Source #

infixR :: [Parser (a -> b -> b)] -> x Source #

prefix :: [Parser (b -> b)] -> x Source #

postfix :: [Parser (b -> b)] -> x Source #

x ~ a => Monolith x a (Level a a) Source #

This instance is used to handle monolithic types where the input and output are the same, it does not require the wrapping function to be provided.

Since: 0.1.0.0

Instance details

Defined in Parsley.Precedence

Methods

infixL :: [Parser (a -> x -> a)] -> Level a a Source #

infixR :: [Parser (x -> a -> a)] -> Level a a Source #

prefix :: [Parser (a -> a)] -> Level a a Source #

postfix :: [Parser (a -> a)] -> Level a a Source #

data Level a b Source #

This datatype represents levels of the precedence table Prec, where each constructor takes many parsers of the same level and fixity.

Since: 0.1.0.0

Constructors

InfixL [Parser (b -> a -> b)] (Defunc (a -> b))

left-associative infix operators

InfixR [Parser (a -> b -> b)] (Defunc (a -> b))

right-associative infix operators

Prefix [Parser (b -> b)] (Defunc (a -> b))

prefix unary operators

Postfix [Parser (b -> b)] (Defunc (a -> b))

postfix unary operators

Instances

Instances details
x ~ a => Monolith x a (Level a a) Source #

This instance is used to handle monolithic types where the input and output are the same, it does not require the wrapping function to be provided.

Since: 0.1.0.0

Instance details

Defined in Parsley.Precedence

Methods

infixL :: [Parser (a -> x -> a)] -> Level a a Source #

infixR :: [Parser (x -> a -> a)] -> Level a a Source #

prefix :: [Parser (a -> a)] -> Level a a Source #

postfix :: [Parser (a -> a)] -> Level a a Source #

data Prec a b where Source #

A heterogeneous list that represents a precedence table so that Prec a b transforms the type a into b via various layers of operators.

Since: 0.1.0.0

Constructors

NoLevel :: Prec a a 
Level :: Level a b -> Prec b c -> Prec a c 

precedence :: Prec a b -> Parser a -> Parser b Source #

This combinator will construct and expression parser will provided with a table of precedence along with a terminal atom.

Since: 0.1.0.0

monolith :: [Level a a] -> Prec a a Source #

A simplified version of precedence that does not use the heterogeneous list Prec, but instead requires all layers of the table to have the same type.

Since: 0.1.0.0