At 01:20 30/05/2004, you wrote:
In my BNF module I use " as an active character that begins and ends terminals in the grammar:
<regex>: <branch> ; <branch>, "\|", <regex>.
Now, the above doesn't quite work as written, as \ is still active (and so is, in fact | as we're really inside a \starttabulate.
What I would like for the "" pair to do is work as a wrapper for \type{}, so that everything in-between is passed on to \type{}. Is there a way of getting them to do that?
This is my current definition:
\gdef"% {\ifBNFoutsidestring% \global\BNFoutsidestringfalse% \begingroup% \BNFunsetcatcodes% \catcode`\"\@@active% \@@bnfterminalstart% \else% \@@bnfterminalstop% \endgroup% \global\BNFoutsidestringtrue% \fi}
I figured something like
\long\gdef"#1"% {\type{#1}}
might work, but it didn't. It chokes on "." where . is also an activated character for terminating a production in the grammar.
Any suggestions on how to go about this? I mean, the obvious solution is simply to write
<regex>: <branch> ; <branch>, "\type{\|}", <regex>.
instead, but I would like to keep the input as clean as possible. nikolai
\definestartstop[BNF][before=\startlines\setups{myBNF},after=\stoplines] \startsetups[myBNF] \defineactivecharacter " {\bgroup\tttf\setupinlineverbatim\defineactivecharacter " {\egroup}} \defineactivecharacter < {\mathematics{\string<}} \defineactivecharacter > {\mathematics{\string>}} \stopsetups \starttext \startBNF <regex>: <branch> ; <branch>, "|", <regex>. \stopBNF \stoptext (cross your fingers that this does not interfere with reading files, but normally < > " are taken care of) an alternative is to write a plugin forthe verbatim environment (see verb-ini to get an idea of what nasty things are involved with catcode changes). Hans