2013-10-21 00:48:02 +00:00
|
|
|
-- AST definition for the Lamb programming language
|
|
|
|
-- Copyright (c) 2013 darkf
|
|
|
|
-- Licensed under the terms of the zlib license, see LICENSE for details
|
|
|
|
|
2013-10-19 06:21:06 +00:00
|
|
|
module AST where
|
2014-11-02 08:14:23 +00:00
|
|
|
import qualified Data.Text as T
|
2013-10-19 06:21:06 +00:00
|
|
|
|
|
|
|
data AST = Add AST AST
|
2013-10-21 00:24:51 +00:00
|
|
|
| Sub AST AST
|
2013-10-19 06:21:06 +00:00
|
|
|
| Mul AST AST
|
2013-10-21 00:24:51 +00:00
|
|
|
| Div AST AST
|
2013-10-23 22:05:47 +00:00
|
|
|
| Equals AST AST
|
|
|
|
| NotEquals AST AST
|
|
|
|
| LessThan AST AST
|
|
|
|
| GreaterThan AST AST
|
2013-10-19 06:21:06 +00:00
|
|
|
| Block [AST]
|
2014-11-02 08:14:23 +00:00
|
|
|
| FunDef T.Text (Pattern, AST)
|
|
|
|
| Defun T.Text AST
|
2013-10-25 09:20:23 +00:00
|
|
|
| Def Pattern AST
|
2014-11-02 08:14:23 +00:00
|
|
|
| Var T.Text
|
2013-10-21 20:18:25 +00:00
|
|
|
| Lambda [(Pattern, AST)]
|
2013-10-29 03:23:29 +00:00
|
|
|
| Call AST AST
|
|
|
|
| Access AST AST
|
2013-10-21 05:27:27 +00:00
|
|
|
| Cons AST AST
|
2013-10-23 21:36:06 +00:00
|
|
|
| IfExpr AST AST AST
|
2013-10-22 22:10:34 +00:00
|
|
|
| TupleConst [AST]
|
2013-10-19 06:21:06 +00:00
|
|
|
| ListConst [AST]
|
2013-10-23 21:41:44 +00:00
|
|
|
| BoolConst Bool
|
2014-11-02 08:14:23 +00:00
|
|
|
| StrConst T.Text
|
2013-10-19 06:21:06 +00:00
|
|
|
| IntConst Integer
|
|
|
|
deriving (Show, Eq)
|
|
|
|
|
2014-11-02 08:14:23 +00:00
|
|
|
data Pattern = VarP T.Text
|
2013-10-19 06:21:06 +00:00
|
|
|
| IntP Integer
|
2014-11-02 08:14:23 +00:00
|
|
|
| StrP T.Text
|
2013-11-02 04:43:36 +00:00
|
|
|
| BoolP Bool
|
2013-10-19 06:21:06 +00:00
|
|
|
| ConsP Pattern Pattern
|
2013-10-22 22:59:05 +00:00
|
|
|
| TupleP [Pattern]
|
2013-10-19 06:21:06 +00:00
|
|
|
| ListP [Pattern]
|
|
|
|
deriving (Show, Eq)
|