-
Notifications
You must be signed in to change notification settings - Fork 0
/
Absmyjs.hs
123 lines (98 loc) · 2.17 KB
/
Absmyjs.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
module Absmyjs where
-- Haskell module generated by the BNF converter
newtype Ident = Ident String deriving (Eq,Ord,Show,Read)
data Program =
Progr [Stmt]
deriving (Eq,Ord,Show,Read)
data MaybeIdent =
NoIdent
| JustIdent Ident
deriving (Eq,Ord,Show,Read)
data Decl =
VarDecl Ident
| VarDeclAssign Ident Expr
| FunDecl FunExpr
deriving (Eq,Ord,Show,Read)
data CompoundStmt =
CS [Stmt]
deriving (Eq,Ord,Show,Read)
data Stmt =
CSS CompoundStmt
| ExprStmt Expr
| DeclStmt Decl
| EmptyStmt
| IfStmt Expr Stmt ElseClause
| WhileStmt Expr Stmt
| ThrowStmt Expr
| TryCatchStmt CompoundStmt Ident CompoundStmt
| ReturnStmt Expr
| EmptyReturnStmt
deriving (Eq,Ord,Show,Read)
data Lvalue =
QIdent [QIdentPart]
deriving (Eq,Ord,Show,Read)
data QIdentPart =
IdentPart IIdent
deriving (Eq,Ord,Show,Read)
data IIdent =
IIdentBare Ident
| IIdentIndexed Ident Expr
deriving (Eq,Ord,Show,Read)
data ParamNames =
ParamNameList [Ident]
deriving (Eq,Ord,Show,Read)
data Params =
ParamList [Param]
deriving (Eq,Ord,Show,Read)
data Param =
ParamExpr Expr
deriving (Eq,Ord,Show,Read)
data KeyValuePair =
KVP Key Expr
deriving (Eq,Ord,Show,Read)
data Key =
KeyIdent Ident
| KeyString String
deriving (Eq,Ord,Show,Read)
data Literal =
IntLiteral Integer
| StringLiteral String
| TrueLiteral
| FalseLiteral
| UndefinedLiteral
| ObjectLiteral [KeyValuePair]
| ArrayLiteral [Param]
deriving (Eq,Ord,Show,Read)
data FunExpr =
Fun MaybeIdent ParamNames CompoundStmt
deriving (Eq,Ord,Show,Read)
data Expr =
FunExpression FunExpr
| AssignExpr Lvalue Expr
| LOrExpr Expr Expr
| LAndExpr Expr Expr
| EqExpr Expr Expr
| NeqExpr Expr Expr
| LessExpr Expr Expr
| GreaterExpr Expr Expr
| LeqExpr Expr Expr
| GeqExpr Expr Expr
| PlusExpr Expr Expr
| MinusExpr Expr Expr
| TimesExpr Expr Expr
| DivExpr Expr Expr
| PreincExpr Lvalue
| PredecExpr Lvalue
| PreopExpr UnaryOp Expr
| ParenExpr Expr
| CallExpr Lvalue Params
| LiteralExpr Literal
| EvalExpr Lvalue
deriving (Eq,Ord,Show,Read)
data UnaryOp =
NegOp
deriving (Eq,Ord,Show,Read)
data ElseClause =
Else Stmt
| ElseEmpty
deriving (Eq,Ord,Show,Read)