syntactical-0.1: Distfix expression parsing library



The modified Shunting-Yard algorithm. The modifications allow function application by juxtaposition (without any paren around the arguments) and distfix operators. For a normal usage, it should be enough to import only Text.Syntactical, not directly this module.



data Shunt a Source


S [SExpr a] [Tree a] [[SExpr a]] (Rule a) 

data Failure a Source

The different failure cases the shunt function can return. The showFailure function can be used to give them a textual representation.


MissingBefore [[a]] a

missing parts before part

MissingAfter [a] [a]

missing parts after parts

CantMix (Part a) (Part a)

can't mix two operators

MissingSubBetween a a

missing sub-expression between parts

MissingSubBefore a

missing sub-expression before string

MissingSubAfter a

missing sub-expression after string

Ambiguity Ambiguity

a part is used ambiguously in multiple operators


this is a bug if it happens


Eq a => Eq (Failure a) 
Show a => Show (Failure a) 

data Rule a Source


Eq a => Eq (Rule a) 
Show a => Show (Rule a) 

shunt :: Token a => Table a -> [SExpr a] -> Either (Failure a) (SExpr a)Source

Parse a list of s-expressions according to an operator table. Usually the s-expressions will be the result of applying Atom to each token.

step :: Token a => Table a -> Shunt a -> Shunt aSource

steps :: Token a => Table a -> [SExpr a] -> IO ()Source

Similar to the shunt function but print the steps performed by the modified shunting yard algorithm. This function is useful to understand (and debug) the modified shunting-yard algorithm.

showFailure :: Token a => Failure a -> StringSource

Give a textual representation of a Failure.