2019-12-27 23:20:18 -08:00
|
|
|
module PythonAst where
|
|
|
|
|
|
|
|
data PyBinOp
|
|
|
|
= Add
|
|
|
|
| Subtract
|
|
|
|
| Multiply
|
|
|
|
| Divide
|
2019-12-30 20:04:39 -08:00
|
|
|
| FloorDiv
|
2019-12-27 23:20:18 -08:00
|
|
|
| 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
|
2020-01-02 21:20:32 -08:00
|
|
|
| TupleLiteral [PyExpr]
|
2019-12-27 23:20:18 -08:00
|
|
|
| FunctionCall PyExpr [PyExpr]
|
|
|
|
| Access PyExpr [PyExpr]
|
|
|
|
| Ternary PyExpr PyExpr PyExpr
|
|
|
|
| Member PyExpr String
|
|
|
|
| In PyExpr PyExpr
|
|
|
|
| NotIn PyExpr PyExpr
|
2019-12-30 20:04:39 -08:00
|
|
|
| Slice (Maybe PyExpr) (Maybe PyExpr)
|
2019-12-27 23:20:18 -08:00
|
|
|
|
|
|
|
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
|
2020-01-02 21:20:32 -08:00
|
|
|
| Import String
|
|
|
|
| FromImport String [String]
|
|
|
|
| Nonlocal [String]
|