Default parameters

Additionally, since most of our boxes use the same parameters, we might as well redefine the default values for in the optional default section so that we may use the abbreviated form of the separator. We leave the box for uminus in place since we want the minus sign flush against the expression. The and boxes both have default values of zero. Our program becomes:


prettyprinter basic of Exp is

constant
   tab = 2 ;

default
   <hv 1,tab,0> ;

rules
   *x !0 -> [<h> "..."] ;
   
   exp_s(**exps,*exp)   -> [<v> ([<h> **exps ";"]) *exp] ;
 
   plus  (*exp1, *exp2) -> [<hv> *exp1  "+" *exp2] ;
   minus (*exp1, *exp2) -> [<hv> *exp1  "-" *exp2] ;
   prod  (*exp1, *exp2) -> [<hv> *exp1  "*" *exp2] ;      

   uminus(*exp)         -> [<h> "-" *exp] ;      

   assign(*var,  *exp2) -> [<hv> *var ":=" *exp2] ;

 end prettyprinter


Tutorial