>> Well, you can write recursive descent parsers, LR(1) parsers (yacc, bison,
>> etc.).
>
>You can't. You can't parse TeX cleanly without context. There might
>be macro, active characters, "unusual" catcodes and thing like that.
Oh, so it's context-sensitive. That's nice :(
>Ideally, you would have to run through everything TeX would have seen
>until it comes to the expression itself. Of course one could made
>"normalizing assumptions" (like "no catcode changes"), but even than the
>scope of \over is not exactly trivial.
Ugly.
>Short of re-implementing TeX itself I see no clean solution.
That's too bad.
>> perl -e 'while(<>){s/(\d+)\s*\\over\s+(\d+)/\\frac{$1}{$2}/g;print;}'
>
>This one fails already on '1\over2' or '1 + 2\over 3'.
Well, as I said, my document's use of it was trivial, mostly limited to simple
fractions, so it fit simple pattern matching. Something like 1 + 2\over 3 never
appeared. 1 + {2 \over 3} and \frac{1+2}{3} might have appeared, but not 1 +
2\over 3.
Writing a general script to convert \over to \frac under all cases sounds tough
-- it sounds like you must almost parse the whole document in order to infer
the context of \over.
All I had to do was convert some simple fractions.
Lee