(* Meta Printer Version 1.3 *) (* Author: Carsten Schuermann *) functor MTPrint (structure Global : GLOBAL structure IntSyn : INTSYN structure FunSyn : FUNSYN sharing FunSyn.IntSyn = IntSyn structure Names : NAMES sharing Names.IntSyn = IntSyn structure StateSyn' : STATESYN sharing StateSyn'.FunSyn = FunSyn sharing StateSyn'.IntSyn = IntSyn structure Formatter' : FORMATTER structure Print : PRINT sharing Print.Formatter = Formatter' sharing Print.IntSyn = IntSyn structure FunPrint : FUNPRINT sharing FunPrint.FunSyn = FunSyn sharing FunPrint.Formatter = Formatter') : MTPRINT = struct structure Formatter = Formatter' structure StateSyn = StateSyn' exception Error of string local structure I = IntSyn structure N = Names structure S = StateSyn structure Fmt = Formatter (* nameState S = S' Invariant: If |- S state and S unnamed then |- S' State and S' named and |- S = S' state *) fun nameState (S.State (n, (G, B), (IH, OH), d, O, H, F)) = let val _ = Names.varReset () val G' = Names.ctxName G in S.State (n, (G', B), (IH, OH), d, O, H, F) end fun formatOrder (G, S.Arg (Us, Vs)) = [Print.formatExp (G, I.EClo Us), Fmt.String ":", Print.formatExp (G, I.EClo Vs)] | formatOrder (G, S.Lex Os) = [Fmt.String "{", Fmt.HVbox0 1 0 1 (formatOrders (G, Os)), Fmt.String "}"] | formatOrder (G, S.Simul Os) = [Fmt.String "[", Fmt.HVbox0 1 0 1 (formatOrders (G, Os)), Fmt.String "]"] and formatOrders (G, nil) = nil | formatOrders (G, O :: nil) = formatOrder (G, O) | formatOrders (G, O :: Os) = formatOrder (G, O) @ [Fmt.String ",", Fmt.Break] @ formatOrders (G, Os) (* format T = fmt' Invariant: If T is a tag then fmt' is a a format descibing the tag T *) fun formatTag (G, S.Parameter l) = [Fmt.String "