The data structures (and associated functions) used in the
parser. For a normal usage, it should be enough
to import only Text.Syntactical
, not directly this module.
- data SExpr a
- data Tree a
- data Op a
- data Opening
- = Infix Associativity
- | Prefix
- | Postfix
- data Associativity
- data Hole
- = SExpression
- | Distfix
- data Part a
- data Table a
- data Priority
- = Lower
- | Higher
- | NoPriority
- 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
- buildTable :: [[Op a]] -> Table a
- cut :: Op a -> [Part a]
- setPrecedence :: Precedence -> Op a -> Op a
- begin :: Part a -> Bool
- end :: Part a -> Bool
- leftOpen :: Part a -> Bool
- rightOpen :: Part a -> Bool
- rightHole :: Part a -> Maybe Hole
- discard :: Part a -> Bool
- applicator :: Token a => Table a -> SExpr a -> Bool
- applicator' :: Token a => Table a -> Tree a -> Bool
- continue :: Token a => Part a -> Part a -> Bool
- original :: Part a -> Op a
- priority :: Part a -> Part a -> Priority
- arity :: Part a -> Int
- symbol :: Part a -> a
- symbols :: Op a -> [a]
- next :: Part a -> [a]
- previous :: Part a -> [a]
- current :: Part a -> [a]
- findBoth :: Token a => Table a -> a -> [Tree a] -> FindBoth a
- findBegin :: Token a => Table a -> a -> FindBegin a
- data FindBegin a
- = NoBegin
- | Begin (Part a)
- | MissingBegin [[a]]
- | AmbiguousBegin Ambiguity
- data FindBoth a
- = BNothing
- | BContinue (Part a)
- | BBegin (Part a)
- | BMissingBegin [[a]]
- | BAmbiguous Ambiguity
- data Ambiguity
- class Token a where
- showPart :: Token a => Part a -> String
- showSExpr :: Token a => SExpr a -> String
- showTree :: Token a => Tree a -> String
Documentation
The s-expression data type used as input and output of the parser. The type is parametrized by the type of the token.
The s-expression data type augmented to represent parts (used in the operator stack).
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.
data Associativity Source
Specify the associativity of an infix operator.
The Hole is used to give various behaviours when dealing with internal holes.
SExpression | SExpression means the |
Distfix | Distfix means the |
A Part represent a single symbol of an operator.
infx :: Associativity -> a -> Op aSource
Build a infix operator. The precedence is set to 0.
infx_ :: Associativity -> a -> Op aSource
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.
closed_ :: a -> Hole -> a -> Op aSource
Build a closed operator with the keep property set to False. The precedence is set to 0.
sexpr :: Op a -> a -> Op aSource
Add a new part separated by an SExpression hole to the right of an operator.
distfix :: Op a -> a -> Op aSource
Add a new part separated by a Distfix hole to the right of an operator.
buildTable :: [[Op a]] -> Table aSource
buildTable
constructs an operator table that can be
used with the shunt
function. Operators are given
in decreasing precedence order.
setPrecedence :: Precedence -> Op a -> Op aSource
Set the precedence of a given operator.
Return the arity of a complete Part. It is an error to call this function on a First or Middle part.
NoBegin | |
Begin (Part a) | |
MissingBegin [[a]] | |
AmbiguousBegin Ambiguity |
BNothing | |
BContinue (Part a) | |
BBegin (Part a) | |
BMissingBegin [[a]] | |
BAmbiguous Ambiguity |
The class of the types that can be parsed.
convert to a string (for showing purpose)
operator :: Op a -> [SExpr a] -> SExpr aSource
create an output node from an operator and its arguments
consider :: a -> a -> BoolSource
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.