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