From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/5880 Path: main.gmane.org!not-for-mail From: Marco Kuhlmann Newsgroups: gmane.comp.tex.context Subject: BNF grammar Date: Tue, 16 Oct 2001 15:27:35 +0200 (MEST) Sender: owner-ntg-context@let.uu.nl Message-ID: <9815.1003238855@www10.gmx.net> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035396445 5382 80.91.224.250 (23 Oct 2002 18:07:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 18:07:25 +0000 (UTC) Original-To: ntg-context@ntg.nl Xref: main.gmane.org gmane.comp.tex.context:5880 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:5880 Hi all! I would like to define an environment "bnfgrammar" to typeset grammars in BNF format. What I thought is that you could type \startbnfgrammar t \BNFis x\in X \BNFcomment{(variable)} \BNFor f(t_1,\dots,t_n) \BNFcomment{(function term)} \stopbnfgrammar and get a properly formatted grammar: t ::= x\in X (variable) | f(t_1,\dots,t_n) (function term) My first try was to use a self-defined tabulate environment: \definetabulate [bnfgrammar] [|lm|cm|lm|] \setuptabulate [bnfgrammar] [inner=\@bnfgrammarsetup] \def\@bnfgrammarsetup{% \def\BNFdf{\NC} \def\BNFis{\NC \mathrel{:=} \NC} \def\BNFor{\NC \NR \NC \NC \mathrel{|} \NC}} This got me quite far, as I can now type: \startbnfgrammar \BNFdf t \BNFis x\in X \BNFor f(t_1,\dots,t_n) \stopbnfgrammar However, the following problems remain: 1. Pagebreaks should not be allowed in the grammar. (Is there an equivalent to the samepage environment for LaTeX?) 2. I would like to get rid of the \BNFdf command. Unfortunately, I was not able to write something like \def\startbnfgrammar{% \start@bnfgrammar \NC} with @bnfgrammar being bnfgrammar from above. I guess this has to do with that the tabulation scans in everything until the next \stoptabulate command and gets confused. 3. How should I implement the \BNFcomment command? I want the comment to be placed in a \hbox of a given width, which then should be aligned on the right text margin. Normally, I would just use \hfill to flush that box to the right, but this does not work with tabulate, as all the widths are calculated on demand. Does anyone has a neat solution to this problem? Is there something better than tabulate for this purpose? Cheers, Marco -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net