111 reputation
3
bio website
location
age
visits member for 1 year, 6 months
seen May 20 '13 at 12:29

May
3
comment TeX document allowing any byte sequence being inserted
As for my above comment which I deleted already, I was wrong. I tested the document \end} and even this works properly.
May
3
comment TeX document allowing any byte sequence being inserted
Now I have a suspicion that it may NOT be possible without using something like eTeX's \everyeof (which is actually quite neat): assume you want to insert a breakage string at position $n$, then let TeX parse the document until character $n$. Then, inspect TeX's parser state, and identify the byte sequence leaving any level of nesting, until no more level is left. Then insert }. All this works only assuming one can at least still write \catcode commands, as it may be needed to close all levels of nesting. But if not, the outer document also has no more way to get back to a "sane" state...
May
3
comment Outright impossible TeX byte sequence
I think I found the/a solution... there is no outright impossible byte sequence at all. Proof: Assume an impossible byte sequence "IMPOSSIBLE" of length $n$ exists. Then set "XYYYYYYYYYY" to a sequence of length $n+1$ consisting of one "X" and $n$ "Y". Then look at this document: \long\def\v#1XYYYYYYYYYY{} \v IMPOSSIBLE ZXYYYYYYYYYY The macro expands to nothing, and TeX has not parsed the contents of the argument yet... which means we win. If it weren't for invalid characters (\catcode 15) and \outer\def's... fixing the catcodes is easy, but can the \outer one (e.g. on "\+") be fixed too?
May
3
awarded  Supporter
May
3
comment TeX document allowing any byte sequence being inserted
This is great, and somewhat equivalent to my solution of putting \end first, then disabling all catcodes (BTW, nice trick with the macro definition \a, removes the need for ordering the catcode assignments right)... but this indeed requires \everyeof to work right. I wonder if it can be proven to be entirely impossible without \everyeof... but not sure.
May
3
comment Outright impossible TeX byte sequence
That actually looks like it's leading somewhere... so what if the "invalid byte sequence" first tries to set the catcode of a character to 15 (invalid)... and tries 256 times so it does not matter WHICH character has the catcode 0... but this won't work if inside \iffalse ... \fi. Which yields another idea... a "long enough" sequence of \fi, where \ cycles through all available characters, so it is more "fi"s than the maximum allowed nesting depth...
May
3
awarded  Nice Question
May
3
awarded  Student
May
3
asked TeX document allowing any byte sequence being inserted
May
3
asked Outright impossible TeX byte sequence