comparison src/source_print.sml @ 30:e6ccf961d8a3

Parsing and printing basic module system
author Adam Chlipala <adamc@hcoop.net>
date Thu, 12 Jun 2008 14:04:22 -0400
parents 067029c748e9
children 44b5405e74c7
comparison
equal deleted inserted replaced
29:537db4ee89f4 30:e6ccf961d8a3
195 p_con' true c] 195 p_con' true c]
196 196
197 197
198 and p_exp e = p_exp' false e 198 and p_exp e = p_exp' false e
199 199
200 fun p_sgn_item (sgi, _) =
201 case sgi of
202 SgiConAbs (x, k) => box [string "con",
203 space,
204 string x,
205 space,
206 string "::",
207 space,
208 p_kind k]
209 | SgiCon (x, NONE, c) => box [string "con",
210 space,
211 string x,
212 space,
213 string "=",
214 space,
215 p_con c]
216 | SgiCon (x, SOME k, c) => box [string "con",
217 space,
218 string x,
219 space,
220 string "::",
221 space,
222 p_kind k,
223 space,
224 string "=",
225 space,
226 p_con c]
227 | SgiVal (x, c) => box [string "val",
228 space,
229 string x,
230 space,
231 string ":",
232 space,
233 p_con c]
234 | SgiStr (x, sgn) => box [string "structure",
235 space,
236 string x,
237 space,
238 string ":",
239 space,
240 p_sgn sgn]
241
242 and p_sgn (sgn, _) =
243 case sgn of
244 SgnConst sgis => box [string "sig",
245 newline,
246 p_list_sep newline p_sgn_item sgis,
247 newline,
248 string "end"]
249 | SgnVar x => string x
250
200 fun p_decl ((d, _) : decl) = 251 fun p_decl ((d, _) : decl) =
201 case d of 252 case d of
202 DCon (x, NONE, c) => box [string "con", 253 DCon (x, NONE, c) => box [string "con",
203 space, 254 space,
204 string x, 255 string x,
234 space, 285 space,
235 string "=", 286 string "=",
236 space, 287 space,
237 p_exp e] 288 p_exp e]
238 289
290 | DSgn (x, sgn) => box [string "signature",
291 space,
292 string x,
293 space,
294 string "=",
295 space,
296 p_sgn sgn]
297 | DStr (x, NONE, str) => box [string "structure",
298 space,
299 string x,
300 space,
301 string "=",
302 space,
303 p_str str]
304 | DStr (x, SOME sgn, str) => box [string "structure",
305 space,
306 string x,
307 space,
308 string ":",
309 space,
310 p_sgn sgn,
311 space,
312 string "=",
313 space,
314 p_str str]
315
316 and p_str (str, _) =
317 case str of
318 StrConst ds => box [string "struct",
319 newline,
320 p_list_sep newline p_decl ds,
321 newline,
322 string "end"]
323 | StrVar x => string x
324
239 val p_file = p_list_sep newline p_decl 325 val p_file = p_list_sep newline p_decl
240 326
241 end 327 end