X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/234b917a6149413bbbeab7dccfaeab5f16e43fe1..411a85f26421358c20b11839310cce6caff8cf77:/src/print.sml?ds=sidebyside diff --git a/src/print.sml b/src/print.sml index 4acf9f1..7e38bb5 100644 --- a/src/print.sml +++ b/src/print.sml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*) + *) (* Pretty-printing Domtool configuration file ASTs *) @@ -59,8 +59,8 @@ fun p_typ' pn (t, _) = | TAction (p, r1, r2) => parenIf pn [p_predBoxed p, space 1, p_record r1, space 1, string "=>", space 1, p_record r2] - | TNested (p1, p2) => - parenIf pn [p_pred' false p1, space 1, string "=>", space 1, p_pred' false p2] + | TNested (p, t) => + parenIf pn [p_pred' false p, space 1, string "=>", space 1, p_typ' false t] | TError => string "" | TUnif (_, ref (SOME t)) => p_typ' pn t @@ -99,6 +99,9 @@ fun p_exp (e, _) = string ":", space 1, dBox [string "(", p_typ t, string ")"], space 1, string "->", space 1, p_exp e, string ")"] + | EALam (x, c, e) => dBox [string "(\\\\", space 1, string x, space 1, + string ":", space 1, p_pred c, + space 1, string "->", space 1, p_exp e, string ")"] | EVar x => string x | EApp (e1, e2) => dBox [string "(", p_exp e1, break {nsp = 1, offset = 0}, p_exp e2, string ")"] @@ -109,14 +112,13 @@ fun p_exp (e, _) = space 1, string x2, string ";", space 1], p_exp e] | ESeq es => dBox (valOf (foldr (fn (e, NONE) => SOME [p_exp e] - | (e, SOME ds) => SOME (dBox [p_exp e, string ";", space 1] :: ds)) + | (e, SOME ds) => SOME (dBox [p_exp e, string ";", newline] :: ds)) NONE es)) - | ELocal (ESeq [e1, e2], _) => dBox [string "let", space 1, - p_exp e1, space 1, - string "in", space 1, - p_exp e2, space 1, - string "end"] - | ELocal e => dBox [string "local(", space 1, p_exp e, string ")"] + | ELocal (e1, e2) => dBox [string "let", space 1, + p_exp e1, space 1, + string "in", space 1, + p_exp e2, space 1, + string "end"] | EWith (e1, (ESkip, _)) => dBox [p_exp e1, space 1, string "with", space 1, string "end"] | EWith (e1, e2) => dBox [p_exp e1, space 1, string "with", p_exp e2, space 1, string "end"] @@ -130,4 +132,7 @@ fun printd d = SM.closeStream myStream end +fun preface (s, d) = printd (PD.hovBox (PD.PPS.Rel 0, + [PD.string s, PD.space 1, d])) + end