50 lines
1.0 KiB
Haskell
50 lines
1.0 KiB
Haskell
module PythonAst where
|
|
|
|
data PyBinOp
|
|
= Add
|
|
| Subtract
|
|
| Multiply
|
|
| Divide
|
|
| FloorDiv
|
|
| LessThan
|
|
| LessThanEq
|
|
| GreaterThan
|
|
| GreaterThanEq
|
|
| Equal
|
|
| NotEqual
|
|
| And
|
|
| Or
|
|
|
|
data PyExpr
|
|
= BinOp PyBinOp PyExpr PyExpr
|
|
| IntLiteral Int
|
|
| StrLiteral String
|
|
| BoolLiteral Bool
|
|
| ListLiteral [PyExpr]
|
|
| DictLiteral [(PyExpr, PyExpr)]
|
|
| Lambda [PyPat] PyExpr
|
|
| Var String
|
|
| Tuple [PyExpr]
|
|
| FunctionCall PyExpr [PyExpr]
|
|
| Access PyExpr [PyExpr]
|
|
| Ternary PyExpr PyExpr PyExpr
|
|
| Member PyExpr String
|
|
| In PyExpr PyExpr
|
|
| NotIn PyExpr PyExpr
|
|
| Slice (Maybe PyExpr) (Maybe PyExpr)
|
|
|
|
data PyPat
|
|
= VarPat String
|
|
| IgnorePat
|
|
| TuplePat [PyPat]
|
|
| AccessPat PyExpr [PyExpr]
|
|
|
|
data PyStmt
|
|
= Assign PyPat PyExpr
|
|
| IfElse PyExpr [PyStmt] [(PyExpr, [PyStmt])] (Maybe [PyStmt])
|
|
| While PyExpr [PyStmt]
|
|
| For PyPat PyExpr [PyStmt]
|
|
| FunctionDef String [String] [PyStmt]
|
|
| Return PyExpr
|
|
| Standalone PyExpr
|