Ppml resource classes

The Ppml language allows you to define a resource class for each token you pretty print. This class may then appear in a resource specification (after Format) followed by a font, foreground, or background property. For example let's reconsider the decision we made to let the default pretty printer handle variable names and numbers.


variable *x    -> [<h> stringpp(*x)];
integer *x -> [<h> integerpp(*x)];

The formatting machine expects a string or tree result from an external function call. Since the variable name is a string We add a class specification as follows:


variable *x    -> [<h> in class = variable : stringpp(*x)];
integer *x -> [<h> in class = number : integerpp(*x)];

which means ``In a resource class named variable (or number), we pretty print the result of stringpp.'' When placed in front of a token or function call, in class affects the token only. When placed in front of a box, it affects every token or function call in the box as well as all tokens formatted by recursive calls. Most recent class specifications have priority, so specifications (for boxes, tokens, or function calls) inside a box preceded by in class override this box specification. Similarly, a class specification in a rule is superceded by class specifications in recursive calls.

Another form of class specification exists, in term class, that when placed in front of a box, affects every token or function call in the current box only. We use this construction to specify a resource class for comments:


comment *x -> 
   [<h> in term class = comment : [<h> "%" stringpp(*x)]];

N.B.


Tutorial