This convenience module re-exports from
Text.Syntactical.Data everything a typical usage of Syntactical
- shunt :: Token a => Table a -> [SExpr a] -> Either (Failure a) (SExpr a)
- steps :: Token a => Table a -> [SExpr a] -> IO ()
- data Failure a
- data Ambiguity
- showFailure :: Token a => Failure a -> String
- data Op a
- data Associativity
- data Hole
- infx :: Associativity -> a -> Op a
- prefx :: a -> Op a
- postfx :: a -> Op a
- closed :: a -> Hole -> a -> Op a
- infx_ :: Associativity -> a -> Op a
- prefx_ :: a -> Op a
- postfx_ :: a -> Op a
- closed_ :: a -> Hole -> a -> Op a
- sexpr :: Op a -> a -> Op a
- distfix :: Op a -> a -> Op a
- arity :: Part a -> Int
- symbol :: Part a -> a
- symbols :: Op a -> [a]
- next :: Part a -> [a]
- previous :: Part a -> [a]
- current :: Part a -> [a]
- data Table a
- buildTable :: [[Op a]] -> Table a
- class Token a where
- data SExpr a
- showSExpr :: Token a => SExpr a -> String
Parse a list of s-expressions according to an operator table.
Usually the s-expressions will be the result of applying
to each token.
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.
|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
missing sub-expression before string
missing sub-expression after string
a part is used ambiguously in multiple operators
this is a bug if it happens
The operator representation, parametrized by the token type. It allows infix, prefix, postfix, and closed operators, with possibly multiple internal holes. Different holes are possible, to drive the parse in specific ways.
Specify the associativity of an infix operator.
The Hole is used to give various behaviours when dealing with internal holes.
SExpression means the
Distfix means the
Build a infix operator with the keep property set to False. The precedence is set to 0.
Build a prefix operator with the keep property set to False. The precedence is set to 0.
Build a postfix operator with the keep property set to False. The precedence is set to 0.
Build a closed operator with the keep property set to False. The precedence is set to 0.
Add a new part separated by an SExpression hole to the right of an operator.
Add a new part separated by a Distfix hole to the right of an operator.
Return the arity of a complete Part. It is an error to call this function on a First or Middle part.
buildTable constructs an operator table that can be
used with the
shunt function. Operators are given
in decreasing precedence order.
The class of the types that can be parsed.
convert to a string (for showing purpose)
create an output node from an operator and its arguments
test if two tokens are the same (used to find match from the operator table). A default definition that compares the result of toString is provided.
The s-expression data type used as input and output of the parser. The type is parametrized by the type of the token.