blog-static/code/cs325-langs/src/PythonAst.hs

50 lines
1.0 KiB
Haskell
Raw Normal View History

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
| Tuple [PyExpr]
| 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