ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: Wrapping \type{}
Date: Tue, 01 Jun 2004 20:33:41 +0200	[thread overview]
Message-ID: <6.1.1.1.2.20040601203125.07daf140@server-1> (raw)
In-Reply-To: <20040529232021.GA3268@puritan.pcp.ath.cx>

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  

  reply	other threads:[~2004-06-01 18:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-29 23:20 Nikolai Weibull
2004-06-01 18:33 ` Hans Hagen [this message]
2004-06-01 21:24   ` Nikolai Weibull
2004-06-23 11:40     ` Patrick Gundlach
2004-06-23 18:15       ` Nikolai Weibull
2004-12-02 14:27         ` BNF module (was: Wrapping \type{}) Patrick Gundlach
2004-12-02 14:43           ` Nikolai Weibull
2004-12-02 14:55             ` BNF module Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6.1.1.1.2.20040601203125.07daf140@server-1 \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).