The Language type that is the core of GroteTrap.
- data Language a = Language {}
- language :: Language a
- data Operator a
- data Fixity1
- data Fixity2
- isUnary :: Operator a -> Bool
- isBinary :: Operator a -> Bool
- isAssoc :: Operator a -> Bool
- findOperator :: Monad m => String -> (Operator a -> Bool) -> [Operator a] -> m (Operator a)
- data Function a = Function {}
- findFunction :: Monad m => String -> [Function a] -> m (Function a)
- function1 :: (a -> a) -> String -> Function a
- function2 :: (a -> a -> a) -> String -> Function a
Language
Language connects the syntax of identifiers, numbers, operators and functions with their semantics. GroteTrap is able to derive a parser and evaluator from a Language, as well as convert between source text selections and tree selections.
An empty language. Use this as the starting base of your languages, setting only those fields that are of importance.
Operators
Representation of an operator.
Fixity for unary operators.
Fixity for infix binary operators.
findOperator :: Monad m => String -> (Operator a -> Bool) -> [Operator a] -> m (Operator a)Source
findOperator name p os
yields the operator from os
that matches the predicate p
and has token name
. Fails if there are no or several matching operators.