Re: TeX syntax? (Joseph H Allen)
25 Feb 2007 12:46:48 -0500

          From comp.compilers

Related articles
TeX syntax? (Russell Shaw) (2007-02-08)
Re: TeX syntax? (glen herrmannsfeldt) (2007-02-09)
Re: TeX syntax? (A Johnstone) (2007-02-09)
Re: TeX syntax? (Allan Adler) (2007-02-09)
Re: TeX syntax? (Philipp Lucas) (2007-02-12)
Re: TeX syntax? (2007-02-16)
Re: TeX syntax? (glen herrmannsfeldt) (2007-02-16)
Re: TeX syntax? (2007-02-25)
Re: TeX syntax? (Jim Hill) (2007-02-25)
| List of all articles for this month |

From: (Joseph H Allen)
Newsgroups: comp.compilers
Date: 25 Feb 2007 12:46:48 -0500
Organization: The World : : Since 1989
References: 07-02-024 07-02-037 07-02-046 07-02-052
Keywords: macros
Posted-Date: 25 Feb 2007 12:46:48 EST

glen herrmannsfeldt <> wrote:
>Joseph H Allen wrote:

>> I made my own preprocessor/format for TeX based on these books. I
>> remember playing a lot of games with the macro name space. For
>> example, only a limited character set can be used in macro names, but
>> I wanted to use any character. I ended up escaping: AA maps to A, AB
>> maps to backslash, AC to {, etc.

>Just about any character can be used in macro names if one really
>wants to do it. LaTeX uses @ in many of its internal names, by
>first changing the catcode of @ to letter, then defining macros
>with @ in the names, or references to those macros. After
>defining all the internal macros, it changes @ back to other.

This is getting off-topic, but may be useful information for those
wanting to use TeX as a back-end- certainly there is a good
possibility that compiler writers would be consulted for such a task

I wanted to have any user defined string in a macro name, so it is not
practical to play evil catcode games. Incidentally, this is for
writing cross reference data as a set of macro definitions to an
auxiliary file.

I was writing the pre-processor, so it was very easy to just remap
characters in the way I describe above. Later, I learned a more
conventional way to do this using \meaning (which is more or less how
\label{} and \ref{} in LaTeX work):

Create a macro called "\a \_$" without messing with the catcodes:

\expandafter\def\csname \meaning a\meaning \meaning \\meaning _\meaning $\endcsname{test}

Expand it:

This is a \csname \meaning a\meaning \meaning \\meaning _\meaning $\endcsname.

The TeX Book would say something like:

Exercise for the reader: create macro \label{foo_} which
writes "\expandafter\def\csname \meaning f\meaning o\meaning o\meaning _\endcsname{12}"
(where 12 is the current page number) to the .aux file.

Also write the matching \ref{}.

Extra points: have \meaning appear only on characters which are not letters.

/* AB1GO */ /* Joseph H. Allen */
int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.