Mercurial > urweb
comparison src/elab_print.sml @ 9:14b533dbe6cc
Added simple expression constructors to Elab
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 26 Jan 2008 17:26:14 -0500 |
parents | a455a9f85cc3 |
children | e97c6d335869 |
comparison
equal
deleted
inserted
replaced
8:a455a9f85cc3 | 9:14b533dbe6cc |
---|---|
126 p_kind k, | 126 p_kind k, |
127 string ">"] | 127 string ">"] |
128 | 128 |
129 and p_con env = p_con' false env | 129 and p_con env = p_con' false env |
130 | 130 |
131 fun p_exp' par env (e, _) = | |
132 case e of | |
133 ERel n => string (#1 (E.lookupERel env n) ^ "_" ^ Int.toString n) | |
134 | ENamed n => string (#1 (E.lookupENamed env n) ^ "__" ^ Int.toString n) | |
135 | EApp (e1, e2) => parenIf par (box [p_exp env e1, | |
136 space, | |
137 p_exp' true env e2]) | |
138 | EAbs (x, t, e) => parenIf par (box [string "fn", | |
139 space, | |
140 string x, | |
141 space, | |
142 string ":", | |
143 space, | |
144 p_con env t, | |
145 space, | |
146 string "=>", | |
147 space, | |
148 p_exp (E.pushERel env x t) e]) | |
149 | ECApp (e, c) => parenIf par (box [p_exp env e, | |
150 space, | |
151 string "[", | |
152 p_con env c, | |
153 string "]"]) | |
154 | ECAbs (exp, x, k, e) => parenIf par (box [string "fn", | |
155 space, | |
156 string x, | |
157 space, | |
158 p_explicitness exp, | |
159 space, | |
160 p_kind k, | |
161 space, | |
162 string "=>", | |
163 space, | |
164 p_exp (E.pushCRel env x k) e]) | |
165 | |
166 | EError => string "<ERROR>" | |
167 | |
168 and p_exp env = p_exp' false env | |
169 | |
131 fun p_decl env ((d, _) : decl) = | 170 fun p_decl env ((d, _) : decl) = |
132 case d of | 171 case d of |
133 DCon (x, n, k, c) => box [string "con", | 172 DCon (x, n, k, c) => box [string "con", |
134 space, | 173 space, |
135 string x, | 174 string x, |
141 p_kind k, | 180 p_kind k, |
142 space, | 181 space, |
143 string "=", | 182 string "=", |
144 space, | 183 space, |
145 p_con env c] | 184 p_con env c] |
185 | DVal (x, n, t, e) => box [string "val", | |
186 space, | |
187 string x, | |
188 string "__", | |
189 string (Int.toString n), | |
190 space, | |
191 string ":", | |
192 space, | |
193 p_con env t, | |
194 space, | |
195 string "=", | |
196 space, | |
197 p_exp env e] | |
146 | 198 |
147 fun p_file env file = | 199 fun p_file env file = |
148 let | 200 let |
149 val (_, pds) = ListUtil.mapfoldl (fn (d, env) => | 201 val (_, pds) = ListUtil.mapfoldl (fn (d, env) => |
150 (ElabUtil.declBinds env d, | 202 (ElabUtil.declBinds env d, |