Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/typechecker/type-error.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/typechecker/type-error.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3418 - (view) (download)

1 : jhr 3385 (* type-error.sml
2 :     *
3 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2015 The University of Chicago
6 :     * All rights reserved.
7 :     *)
8 :    
9 :     structure TypeError : sig
10 :    
11 :     datatype token
12 : jhr 3418 = S of string (* literal string *)
13 :     | A of Atom.atom (* atom; will print in single quotes ('...') *)
14 :     | V of AST.var (* AST variable; will print name in single quotes ('...') *)
15 :     | TY of Types.ty (* type expression *)
16 :     | TYS of Types.ty list (* list of types *)
17 :     | LN of Error.location (* source-code location; prints as a line number *)
18 : jhr 3385
19 : jhr 3413 (* format an error message *)
20 :     val format : token list -> string list
21 :    
22 : jhr 3385 (* record a warning message *)
23 :     val warning : (Error.err_stream * Error.span) * token list -> unit
24 :    
25 :     (* record an error message *)
26 :     val error : (Error.err_stream * Error.span) * token list -> unit
27 :    
28 :     end = struct
29 :    
30 : jhr 3401 structure TU = TypeUtil
31 :    
32 : jhr 3385 datatype token
33 :     = S of string | A of Atom.atom
34 :     | V of AST.var | TY of Types.ty | TYS of Types.ty list
35 : jhr 3413 | LN of Error.location
36 : jhr 3385
37 :     fun tysToString tys = String.concat[
38 :     "(", String.concatWith " * " (List.map TU.toString tys), ")"
39 :     ]
40 :     fun tok2str (S s) = s
41 :     | tok2str (A a) = concat["'", Atom.toString a, "'"]
42 :     | tok2str (V x) = concat["'", Var.nameOf x, "'"]
43 :     | tok2str (TY ty) = TU.toString ty
44 :     | tok2str (TYS []) = "()"
45 :     | tok2str (TYS[ty]) = TU.toString ty
46 :     | tok2str (TYS tys) = tysToString tys
47 : jhr 3413 | tok2str (LN loc) = Error.fmt ("%l", "<unknown>") loc
48 : jhr 3385
49 : jhr 3413 fun format toks = List.map tok2str toks
50 :    
51 : jhr 3385 fun warning ((errStrm, span), toks) = Error.warningAt(errStrm, span, List.map tok2str toks)
52 : jhr 3401 fun error ((errStrm, span), toks) = Error.errorAt(errStrm, span, List.map tok2str toks)
53 : jhr 3385
54 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0