Copyright | (C) CSIRO 2017-2019 |
---|---|
License | BSD3 |
Maintainer | Isaac Elliott <isaace71295@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module contains a datatype for binary operators and a precedence table with associated operations. This presentation of operators is simpler and more flexible than hard-coding them into the syntax tree.
Synopsis
- data BinOp a
- = Is (Ann a) [Whitespace]
- | IsNot (Ann a) [Whitespace] [Whitespace]
- | In (Ann a) [Whitespace]
- | NotIn (Ann a) [Whitespace] [Whitespace]
- | Minus (Ann a) [Whitespace]
- | Exp (Ann a) [Whitespace]
- | BoolAnd (Ann a) [Whitespace]
- | BoolOr (Ann a) [Whitespace]
- | Eq (Ann a) [Whitespace]
- | Lt (Ann a) [Whitespace]
- | LtEq (Ann a) [Whitespace]
- | Gt (Ann a) [Whitespace]
- | GtEq (Ann a) [Whitespace]
- | NotEq (Ann a) [Whitespace]
- | Multiply (Ann a) [Whitespace]
- | Divide (Ann a) [Whitespace]
- | FloorDivide (Ann a) [Whitespace]
- | Percent (Ann a) [Whitespace]
- | Plus (Ann a) [Whitespace]
- | BitOr (Ann a) [Whitespace]
- | BitXor (Ann a) [Whitespace]
- | BitAnd (Ann a) [Whitespace]
- | ShiftLeft (Ann a) [Whitespace]
- | ShiftRight (Ann a) [Whitespace]
- | At (Ann a) [Whitespace]
- data Assoc
- data OpEntry = OpEntry {}
- opPrec :: Lens' OpEntry Int
- opOperator :: Lens' OpEntry (BinOp ())
- opAssoc :: Lens' OpEntry Assoc
- operatorTable :: [OpEntry]
- sameOperator :: BinOp a -> BinOp a' -> Bool
- isComparison :: BinOp a -> Bool
- lookupOpEntry :: BinOp a -> [OpEntry] -> OpEntry
Documentation
A Python binary operator, such as +
, along with its trailing Whitespace
Is (Ann a) [Whitespace] | a is b |
IsNot (Ann a) [Whitespace] [Whitespace] | a is not b |
In (Ann a) [Whitespace] | a in b |
NotIn (Ann a) [Whitespace] [Whitespace] | a not in b |
Minus (Ann a) [Whitespace] | a - b |
Exp (Ann a) [Whitespace] | a ** b |
BoolAnd (Ann a) [Whitespace] | a and b |
BoolOr (Ann a) [Whitespace] | a or b |
Eq (Ann a) [Whitespace] | a == b |
Lt (Ann a) [Whitespace] | a < b |
LtEq (Ann a) [Whitespace] | a <= b |
Gt (Ann a) [Whitespace] | a > b |
GtEq (Ann a) [Whitespace] | a >= b |
NotEq (Ann a) [Whitespace] | a != b |
Multiply (Ann a) [Whitespace] | a * b |
Divide (Ann a) [Whitespace] | a / b |
FloorDivide (Ann a) [Whitespace] | a // b |
Percent (Ann a) [Whitespace] | a % b |
Plus (Ann a) [Whitespace] | a + b |
BitOr (Ann a) [Whitespace] | a | b |
BitXor (Ann a) [Whitespace] | a ^ b |
BitAnd (Ann a) [Whitespace] | a & b |
ShiftLeft (Ann a) [Whitespace] | a << b |
ShiftRight (Ann a) [Whitespace] | a >> b |
At (Ann a) [Whitespace] |
|
Instances
The associativity of an operator. Each operator is either left-associative or right associative.
Left associative:
x + y + z = (x + y) + z
Right associative:
x + y + z = x + (y + z)
An operator along with its precedence and associativity.
operatorTable :: [OpEntry] Source #
operatorTable
is a list of all operators in ascending order of precedence.