In the following pdftex example we make verbatim environment inside "...", i.e., all special characters get catcode 12. The problem is with {:
\def\setverb{\def\do##1{\catcode`##1=12}\dospecials}
\catcode`\"=\active
\def"#1"{%
\leavevmode\hbox{%
\setverb
\tt
\endlinechar=-1 \scantokens{#1}%
}%
}
hello "{" world
\bye
Why it gives this error?
(./test.tex
Runaway argument?
{" world
! Forbidden control sequence found while scanning use of ".
<inserted text>
\par
<to be read again>
\bye
l.13 \bye
?
Should not it tokenize arguments until it encounters the second "?
How to make \def"#1"{...} work in all cases?
\def"#1#2"{arg1: #1 arg2: #2}and"{abc}d"will givearg1: abc arg2: d. So braces must be balanced. Check the definition of\verbin latex.ltx for a solution. – Ulrike Fischer Aug 10 '16 at 07:48