Commit 57c909f3 authored by Raphaël Cauderlier's avatar Raphaël Cauderlier
Browse files

Printing functions of scoped terms for error messages

parent 8724574f
......@@ -102,3 +102,55 @@ let rec scope_prog ty_env const_env = function
sline :: scope_prog nty_env nconst_env prog
let scope = scope_prog [] []
let string_of_id (Id s) = s
let string_of_cid (Cid s) = s
let string_of_label (Label s) = s
let rec string_of_sty = function
| Stcid (cid, sty) -> Printf.sprintf "%s {= %s}" (string_of_cid cid) (string_of_sty sty)
| Stlist ll ->
Printf.sprintf "[ %s ]"
(String.concat " ; "
(List.map
(fun (l, sty) ->
Printf.sprintf "%s : %s"
(string_of_label l) (string_of_sty sty))
ll))
| Starr (sty1, sty2) ->
Printf.sprintf "(%s -> %s)"
(string_of_sty sty1)
(string_of_sty sty2)
let rec string_of_sterm = function
| Svar (id, sty) -> Printf.sprintf "%s {: %s}"
(string_of_id id) (string_of_sty sty)
| Sconst (id, sty, sterm) -> Printf.sprintf "%s {: %s = %s}"
(string_of_id id) (string_of_sty sty) (string_of_sterm sterm)
| Spar sterm -> Printf.sprintf "(%s)" (string_of_sterm sterm)
| Sapp (sterm1, sterm2) -> Printf.sprintf "%s @ %s"
(string_of_sterm sterm1) (string_of_sterm sterm2)
| Sabst (id, sty, sterm) -> Printf.sprintf "λ(%s : %s) %s"
(string_of_id id) (string_of_sty sty) (string_of_sterm sterm)
| Sobj ll ->
Printf.sprintf "[ %s ]"
(String.concat " ; "
(List.map
(fun (l, m) ->
Printf.sprintf "%s = %s"
(string_of_label l) (string_of_smeth m))
ll))
| Ssel (sterm, label) -> Printf.sprintf "%s.%s"
(string_of_sterm sterm) (string_of_label label)
| Supd (sterm, label, m) -> Printf.sprintf "%s.%s<=%s"
(string_of_sterm sterm) (string_of_label label) (string_of_smeth m)
| Sfupd (sterm, label, body) -> Printf.sprintf "%s.%s:=%s"
(string_of_sterm sterm) (string_of_label label) (string_of_sterm body)
and string_of_smeth (Smeth (id, sty, sterm)) =
Printf.sprintf "ς(%s : %s) %s"
(string_of_id id) (string_of_sty sty) (string_of_sterm sterm)
......@@ -27,3 +27,15 @@ type sline =
type scoped_tree = sline list
val scope : (Lexing.position * Parsetree.line) list -> scoped_tree
val string_of_id : id -> string
val string_of_cid : cid -> string
val string_of_label : label -> string
val string_of_sty : sty -> string
val string_of_sterm : sterm -> string
val string_of_smeth : smeth -> string
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment