I am looking for tools or techniques that can partially evaluate (e.g. inline definitions) a TeX source file into an equivalent, simplified TeX file with some parameters fixed.
Specifically I would be interested in a solution achieving the following:
eliminate unreachable branches of
\if. For example it should be able to simplify\newif\ifbla \blatrue \ifbla GOOD \else BAD \fito
GOOD.Inline macro definitions. For example transforming
\def\bla#1{bla to #1} \begingroup \def\bla#1{blerp at #1} \bla{me}, \endgroup \bla{you}to
blerp at me, bla to youInline files (with the aim of combining this with point 2 in compiling a standalone tex source).
The main difficulty in doing this is reliability: the macro system makes any naive parser break very quickly in the presence of non-trivial macro (re-)definitions.
\blatrueto\blafalse, for instance. – egreg Sep 20 '13 at 12:52\blatoken. I am aware it's a daunting task to implement it but I wanted to know if anybody attempted to do something like that. – Bordaigorl Sep 20 '13 at 13:54\catcodeand all forms of\defand\letwould have to be evaluated, but since you don't want typesetting you would have to leave, say,\hboxunevaluated. Except that inside an\hboxthere is effectively an entire new document that needs "partial evaluation". And you would need to evaluate some boxes, for example\box0=\hbox{x}\ifdim\wd0>0.... (continued) – Ryan Reich Sep 20 '13 at 14:06