-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAST.hs
More file actions
56 lines (51 loc) · 2.49 KB
/
AST.hs
File metadata and controls
56 lines (51 loc) · 2.49 KB
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
module AST(CTypeDeclaration(..),
CDefinition(..),
CExpression(..),
CStatement(..),
CTranslationUnit)
where
data CTypeDeclaration = CPrimitiveTypeDeclaration String
| CTypedefTypeDeclaration String
| CStructDeclaration String
| CPointerDeclaration CTypeDeclaration
deriving Show
data CDefinition = CTypedefDefinition CTypeDeclaration String
| CStructDefinition String [(CTypeDeclaration, String)]
| CVariableDefinition CTypeDeclaration String (Maybe CExpression)
| CFunctionDefinition CTypeDeclaration String [(CTypeDeclaration, String)] CStatement
| CExternDefinition CTypeDeclaration String String [(CTypeDeclaration, String)]
deriving Show
data CExpression = CStringLiteral String
| CCharLiteral Char
| CIntLiteral Integer
| CSymbol String
| CAssign CExpression CExpression
| CDereference CExpression
| CAddressOf CExpression
| CArrayRef CExpression CExpression
| CBinDot CExpression CExpression
| CBinLessThan CExpression CExpression
| CBinGreaterThan CExpression CExpression
| CBinLessEqual CExpression CExpression
| CBinGreaterEqual CExpression CExpression
| CEquals CExpression CExpression
| CNotEquals CExpression CExpression
| CBinPlus CExpression CExpression
| CBinMinus CExpression CExpression
| CBinMul CExpression CExpression
| CBinDiv CExpression CExpression
| CUnPlus CExpression
| CUnMinus CExpression
| CCall String [CExpression]
| CExternCall String String [CExpression]
deriving Show
data CStatement = CBlock [CStatement]
| CAllocate String CExpression
| CExpressionStatement CExpression
| CIfElse CExpression CStatement (Maybe CStatement)
| CWhile CExpression CStatement
| CFor (Maybe CExpression, Maybe CExpression, Maybe CExpression) CStatement
| CLet [CDefinition] CStatement
| CReturn (Maybe CExpression)
deriving Show
type CTranslationUnit = [CDefinition]