Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/compiler/Elaborator/print/ppast.sml
ViewVC logotype

Diff of /sml/trunk/compiler/Elaborator/print/ppast.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3304, Tue Apr 28 06:09:28 2009 UTC revision 3305, Tue Apr 28 18:42:17 2009 UTC
# Line 217  Line 217 
217          | ppExp' (FnExp nil,_,d) = pps "<function>"          | ppExp' (FnExp nil,_,d) = pps "<function>"
218          | ppExp' (FnExp rules,_,d)=          | ppExp' (FnExp rules,_,d)=
219                  let fun pr _ pat = ppRule context ppstrm(pat, d-1)                  let fun pr _ pat = ppRule context ppstrm(pat, d-1)
220                  in ppSequence ppstrm                  in
221                     {sep=(fn ppstrm => (PP.string ppstrm "|";break ppstrm {nsp=0,offset=0})),                      pps "fn"; break ppstrm {nsp=1,offset=0};
222                        ppSequence ppstrm
223                                   {sep=(fn ppstrm =>
224                                            (PP.string ppstrm "|";
225                                             break ppstrm {nsp=0,offset=0})),
226                      pr=pr,                      pr=pr,
227                      style=INCONSISTENT}                      style=INCONSISTENT}
228                     rules                     rules
229                  end                  end
   
230          | ppExp' (FlatAppExp fap,_,d) =          | ppExp' (FlatAppExp fap,_,d) =
231                  let fun pr _ {item,fixity,region} = ppExp'(item,true, d)                  let fun pr _ {item,fixity,region} = ppExp'(item,true, d)
232                  in ppSequence ppstrm                  in ppSequence ppstrm
# Line 260  Line 263 
263                  break ppstrm {nsp=1,offset=0};                  break ppstrm {nsp=1,offset=0};
264                  pps "end";                  pps "end";
265                 closeBox ())                 closeBox ())
266            | ppExp'(SeqExp [expr],_,d) = ppExp'(expr,false,d-1)
267          | ppExp'(SeqExp exps,_,d) =          | ppExp'(SeqExp exps,_,d) =
268                ppClosedSequence ppstrm                ppClosedSequence ppstrm
269                  {front=(C PP.string "("),                  {front=(C PP.string "("),
# Line 318  Line 322 
322                (openHVBox 0;                (openHVBox 0;
323                  lpcond(atom);                  lpcond(atom);
324                  pps "#"; ppSym ppstrm name;                  pps "#"; ppSym ppstrm name;
                 pps ">";  
325                  rpcond(atom);                  rpcond(atom);
326                 closeBox ())                 closeBox ())
327          | ppExp' (ConstraintExp {expr,constraint},atom,d) =          | ppExp' (ConstraintExp {expr,constraint},atom,d) =
# Line 506  Line 509 
509                 (pps "struct"; nbSpace ppstrm 1; pps "end")                 (pps "struct"; nbSpace ppstrm 1; pps "end")
510             | ppStrExp'(BaseStr de, d) =             | ppStrExp'(BaseStr de, d) =
511                 (openVBox ppstrm (Rel 0);                 (openVBox ppstrm (Rel 0);
512                  pps "stuct";  PU.nl_indent ppstrm 2;                  pps "struct";  PU.nl_indent ppstrm 2;
513                  ppDec context ppstrm (de, d-1);                  ppDec context ppstrm (de, d-1);
514                    break ppstrm {nsp=1, offset=0};
515                  pps "end";                  pps "end";
516                  PP.closeBox ppstrm)                  PP.closeBox ppstrm)
517             | ppStrExp'(ConstrainedStr (stre, constraint), d) =             | ppStrExp'(ConstrainedStr (stre, constraint), d) =
# Line 1187  Line 1191 
1191          fun ppStrb'(_,0)= pps "<Strb>"          fun ppStrb'(_,0)= pps "<Strb>"
1192            | ppStrb'(Strb{name,def,constraint},d) =            | ppStrb'(Strb{name,def,constraint},d) =
1193               (openHVBox ppstrm (PP.Rel 0);               (openHVBox ppstrm (PP.Rel 0);
1194                ppSym ppstrm name; PP.string ppstrm " :";                ppSym ppstrm name; PP.string ppstrm " =";
1195                break ppstrm {nsp=1,offset=2}; ppStrExp context ppstrm (def,d-1);                break ppstrm {nsp=1,offset=2}; ppStrExp context ppstrm (def,d-1);
1196                closeBox ppstrm)                closeBox ppstrm)
1197            | ppStrb'(MarkStrb (t,r),d) = ppStrb context ppstrm (t,d)            | ppStrb'(MarkStrb (t,r),d) = ppStrb context ppstrm (t,d)
# Line 1327  Line 1331 
1331    
1332  end (* top-level local *)  end (* top-level local *)
1333  end (* structure PPAst *)  end (* structure PPAst *)
1334    
1335    (* 4/28/2009: Fixed some "bugs" in the pretty printer that were making
1336       "round trips" fail ((pp o parse o pp o parse) s != (pp o parse) s).
1337       Specifically:
1338    
1339       - The "fn" was not being prepended to FnExp's.
1340    
1341       - Removed parenthesis for sequence expressions of one
1342         subexpression.  (Iteratively sending this back to the parser kept
1343         adding nested parenthesis.)
1344    
1345       - A ">" was being appended after selector expressions ("#x" would
1346         pretty print as "#x>").
1347    
1348       - Fixed spelling error (was "stuct") and added whitespace between the
1349         structure body and the "end" keyword for BaseStr's.
1350    
1351       - Changed ":" to "=" for Strb's (note that constraints were not and
1352         are still not handled).
1353    
1354       Jon Riehl *)

Legend:
Removed from v.3304  
changed lines
  Added in v.3305

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