Consider the following MWE, test.tex:
\documentclass[12pt]{article}
\begin{document}
\tracingassigns=1
\tracingmacros=1
\def\aaa{something}
\def\bbb{else \aaa, else}
\edef\ccc{third \bbb, level}
\tracingassigns=0
\tracingmacros=0
\end{document}
If you build this with pdflatex test.tex - then in the logfile, test.log, you get something like this (linebreaks added for legibility):
{into \tracingassigns=1}
{changing \tracingmacros=0}
{into \tracingmacros=1}
{changing \aaa=undefined}
{into \aaa=macro:->something}
{changing \bbb=undefined}
{into \bbb=macro:->else \aaa , else}
\bbb ->else \aaa , else
\aaa ->something
{changing \ccc=undefined}
{into \ccc=macro:->third else something, else, le\ETC.}
{changing \tracingassigns=1}
Now, this explains the expansion steps done by (La)Tex quite well for this short example - unfortunately, it becomes extremely hard to read (for me) once you have to deal with possibly hundreds of these expansions, some maybe dealing with typesetting procedures.
So I was thinking - it shouldn't be too extremely difficult to build an application, which would basically read the logfile line by line, and allow for "stepping" through the logfile; I'd imagine rightarrow keyboard key -> would step you forward through the log, and leftarrow key <- would step backwards; possibly, one could specify line number of the logfile as a starting point as well.
Then, the application would simply react on '^{changing', '^{into', and possibly '^\\(.*)->(.*)'; and would display the line, as well as the "current" token elsewhere on screen; so at the "changing" line, the extra portion of the screen would say \aaa=undefined; and upon "into" line, the snippet would change to \aaa=macro:->something.
I think just this facility would make visualizing and understanding the (La)Tex expansion process much more easy (especially in "real" documents). And in fact, such an application doesn't even need a full-blown GUI - I'd imagine a ncurses terminal application would do just as well (problems with display of long strings in limited width terminal notwithstanding).
So, I was wondering - is there any application similar to this out there?
\def\a#1;{8#18}\expandafter\a\number\a2;;At first, a simple macro definition, then{\expandafter},{\number},\a #1;->8#18,#1<-2,\a #1;->8#18,#1<-828... Very hard to keep track of which\ais being expanded when. I suspect that the correct approach would be to modify the engine itself, but I still don't know how the expansion would be displayed. – Bruno Le Floch Jun 24 '12 at 9:04