Rename "tiger" dir to "compiler"
[tiger.ml.git] / compiler / src / lib / tiger / tiger_absyn.ml
CommitLineData
28875fec
SK
1type pos = Tiger_position.t
2
3type symbol = Tiger_symbol.t
4
5type oper =
6 | PlusOp
7 | MinusOp
8 | TimesOp
9 | DivideOp
10 | EqOp
11 | NeqOp
12 | LtOp
13 | LeOp
14 | GtOp
15 | GeOp
16
17type exp =
18 | VarExp of
19 var
20 | NilExp
21 | IntExp of
22 int
23 | StringExp of
24 { string : string
25 ; pos : pos
26 }
27 | CallExp of
28 { func : symbol
29 ; args : exp list
30 ; pos : pos
31 }
32 | OpExp of
33 { left : exp
34 ; oper : oper
35 ; right : exp
36 ; pos : pos
37 }
38 | RecordExp of
39 { fields : (symbol * exp * pos) list
40 ; typ : symbol
41 ; pos : pos
42 }
43 | SeqExp of
44 (exp * pos) list
45 | AssignExp of
46 { var : var
47 ; exp : exp
48 ; pos : pos
49 }
50 | IfExp of
51 { test : exp
52 ; then' : exp
53 ; else' : exp option
54 ; pos : pos
55 }
56 | WhileExp of
57 { test : exp
58 ; body : exp
59 ; pos : pos
60 }
61 | ForExp of
62 { var : symbol
63 ; escape : bool ref (* Whoa - why a mutable cell in AST? *)
64 ; lo : exp
65 ; hi : exp
66 ; body : exp
67 ; pos : pos
68 }
69 | BreakExp of
70 pos
71 | LetExp of
72 { decs : dec list
73 ; body : exp
74 ; pos : pos
75 }
76 | ArrayExp of
77 { typ : symbol
78 ; size : exp
79 ; init : exp
80 ; pos : pos
81 }
82and var =
83 | SimpleVar of
84 { symbol : symbol
85 ; pos : pos
86 }
87 | FieldVar of
88 { var : var
89 ; symbol : symbol
90 ; pos : pos
91 }
92 | SubscriptVar of
93 { var : var
94 ; exp : exp
95 ; pos : pos
96 }
97and dec =
98 | FunDecs of (* "FunctionDec" in Appel's code *)
99 fundec list
100 | VarDec of
101 { name : symbol
102 ; escape : bool ref (* Again, why mutable? *)
103 ; typ : (symbol * pos) option
104 ; init : exp
105 ; pos : pos
106 }
107 | TypeDecs of (* "TypeDec" in Appel's code *)
108 typedec list
109and ty =
110 | NameTy of
111 { symbol : symbol
112 ; pos : pos
113 }
114 | RecordTy of
115 field list
116 | ArrayTy of
117 { symbol : symbol
118 ; pos : pos
119 }
120and field =
121 | Field of
122 { name : symbol
123 ; escape : bool ref
124 ; typ : symbol
125 ; pos : pos
126 }
127and typedec =
128 | TypeDec of (* An anonymous record in Appel's code *)
129 { name : symbol
130 ; ty : ty
131 ; pos : pos
132 }
133and fundec =
134 | FunDec of
135 { name : symbol
136 ; params : field list
137 ; result : (symbol * pos) option
138 ; body : exp
139 ; pos : pos
140 }
141
142type t = exp
143
144let to_string _ = "TODO: implement Tiger_absyn.to_string"
This page took 0.027182 seconds and 4 git commands to generate.