From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/14832 Path: main.gmane.org!not-for-mail From: Nikolai Weibull Newsgroups: gmane.comp.tex.context Subject: \doifnextcharelse problem Date: Thu, 26 Feb 2004 17:38:13 +0100 Sender: ntg-context-admin@ntg.nl Message-ID: <20040226163813.GG26896@puritan.pcp.ath.cx> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" X-Trace: sea.gmane.org 1077813708 31043 80.91.224.253 (26 Feb 2004 16:41:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 26 Feb 2004 16:41:48 +0000 (UTC) Original-X-From: ntg-context-admin@ntg.nl Thu Feb 26 17:41:24 2004 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AwOZg-0000UK-00 for ; Thu, 26 Feb 2004 17:41:24 +0100 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id 03A6510B2A; Thu, 26 Feb 2004 17:37:43 +0100 (MET) Original-Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by ref.ntg.nl (Postfix) with ESMTP id D280610B26 for ; Thu, 26 Feb 2004 17:36:13 +0100 (MET) Original-Received: from puritan.pcp.ath.cx ([213.112.43.212] [213.112.43.212]) by mxfep01.bredband.com with ESMTP id <20040226163812.THUQ13599.mxfep01.bredband.com@puritan.pcp.ath.cx> for ; Thu, 26 Feb 2004 17:38:12 +0100 Original-Received: by puritan.pcp.ath.cx (Postfix, from userid 1000) id: 38:13 +0100 (CET) Original-To: ntg-context@ntg.nl Content-Disposition: inline User-Agent: Mutt/1.5.5.1i Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:14832 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:14832 --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline It seems that I can't get \definecomplexorsimpleempty to work right. The command I define works fine unless the simple version is called, in which case the first character in the body of the command is checked \doifnextcharelse[... which thus fails but in some manner eats it (even though it is output). The problem with the \doifnextcharelse is that the character it checks against is \catcode'd to \@@active, but it won't work when the character has been checked. Is there any way to fix this? I understand if my problem isn't that clear, so I've attached the module. The idea is to be able to write \startbnfgrammar : . : "0";"1". \stopbnfgrammar and this is then typeset as a table, but currently you're forced to write \startbnfgrammar[] : . : "0";"1". \stopbnfgrammar or the first < in gets eaten by \doifnextcharelse and the \def<{... won't be called causing problems down the line when the > is encountered, which expands into a \egroup which stops tex as there is no matching \bgroup. Now, is there any way to get \doifnextcharelse to properly deal with \catcode'd characters (such as my <) that it encounters when looking for other characters (such as the [ for optional arguments to commands)? I'd really like to resolve this, so any comments or tips are appreciated. Second, is there any good reference to programming TeX? I mean, one can figure out most stuff from reading CONTEXT's source for example, but it would be great to find out the exact implications of builtins such as \relax and so on. nikolai -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);} --Nq2Wo0NMKNjxTN9z Content-Type: application/x-tex Content-Disposition: attachment; filename="m-bnf.tex" Content-Transfer-Encoding: quoted-printable % TODO: look at core-tab.tex to see how to make | (;) and " work better=0A%= XXX: there's a problem with \doifnextcharelse{} in that it won't allow the= =0A% character read to be \catcode:d=0A\writestatus{loading}{BNF Macros / I= nitialization}=0A=0A\unprotect=0A=0A\definesystemvariable{bnf}=0A=0A\startc= onstants english=0A terminalstart: terminalstart=0A terminalstop: = terminalstop=0A nonterminalstart: nonterminalstart=0A nonterminalstop: n= onterminalstop=0A colon: colon=0A semicolon: semicolon=0A period:= period=0A comma: comma=0A\stopconstants=0A=0A\startvariables english= =0A bnfgrammar: bnfgrammar=0A bnfgrammars: bnfgrammars=0A\stopvariabl= es=0A=0A\startcommands english=0A setupbnfgrammar: setupbnfgrammar=0A s= tartbnfgrammar: startbnfgrammar=0A stopbnfgrammar: stopbnfgrammar=0A\sto= pcommands=0A=0A\def\setcatcodes%=0A {\catcode`\"\@@active%=0A \catcode`\= :\@@active%=0A \catcode`\,\@@active%=0A \catcode`\;\@@active%=0A \cat= code`\.\@@active%=0A \catcode`\<\@@active%=0A \catcode`\>\@@active}=0A= =0A\def\uncatcodecharacters%=0A {\catcode`\"\@@other%=0A \catcode`\:\@@o= ther%=0A \catcode`\,\@@other%=0A \catcode`\;\@@other%=0A \catcode`\.\= @@other%=0A \catcode`\<\@@other%=0A \catcode`\>\@@other}=0A=0A\let\esca= pegrammar=3D\uncatcodecharacters=0A=0A\bgroup=0A \uncatcodecharacters=0A = \glet\quotesymbol=3D"=0A \glet\lessthan=3D<=0A \glet\greaterthan=3D>=0A\e= group=0A=0A\newif\ifoutsidestring \outsidestringtrue=0A=0A\newif\iffirstrul= e \firstruletrue=0A\newif\ifnewrule \newruletrue=0A\newif\ifdonerule \doner= ulefalse=0A=0A\bgroup=0A\setcatcodes=0A\gdef\defcolon#1%=0A {\catcode`\:\@= @active=0A \def:{\NC {\uncatcodecharacters #1} \NC}=0A \catcode`\:\@@ot= her}=0A\gdef\defcomma#1%=0A {\catcode`\,\@@active=0A \def,{{\uncatcodech= aracters #1}}=0A \catcode`\,\@@other}=0A\gdef\defsemicolon#1%=0A {\catco= de`\;\@@active=0A \def;{{\uncatcodecharacters #1}}=0A \catcode`\;\@@oth= er}=0A\gdef\defperiod#1%=0A {\catcode`\.\@@active=0A \def.{{\uncatcodech= aracters #1}=0A \NC%=0A \global\newruletrue%=0A \global\doneruletrue}=0A= \catcode`\.\@@other}=0A\gdef\defnonterminal#1#2%=0A {\catcode`\<\@@acti= ve=0A \catcode`\>\@@active=0A \def<%=0A {\ifnewrule=0A \ifdo= nerule=0A \iffirstrule=0A \FR%=0A \global\firstrulefalse%=0A \e= lse=0A \MR%=0A \fi=0A \fi=0A \global\newrulefalse%=0A \NC%=0A = \fi=0A \begingroup%=0A #1%=0A \uncatcodecharacters%= =0A \catcode`\>\@@active}=0A \def>%=0A {#2%=0A \endgroup}=0A \= catcode`\<\@@other=0A \catcode`\>\@@other}=0A\gdef\defterminal#1#2%=0A {= \catcode`\"\@@active=0A \def"%=0A {\ifoutsidestring=0A \global= \outsidestringfalse%=0A \begingroup%=0A \uncatcodecharacter= s%=0A \catcode`\"\@@active%=0A #1%=0A \else=0A #2%=0A \en= dgroup%=0A \global\outsidestringtrue%=0A \fi}=0A \catcode`\"\= @@other}=0A\egroup=0A=0A% TODO: it's probably enough to call \getparameters= [\??bnf][#1]% instead of=0A% \setupbnfgrammar[#1]% here=0A\def\complexstart= bnfgrammar[#1]%=0A {\bgroup%=0A \global\firstruletrue%=0A \global\newr= uletrue%=0A \global\donerulefalse%=0A \setupbnfgrammar[#1]%=0A \setca= tcodes%=0A \starttable[|r|c|l|]}=0A=0A\definecomplexorsimpleempty\startbn= fgrammar=0A=0A\def\stopbnfgrammar=0A {\LR%=0A \stoptable%=0A \uncatcod= echaracters%=0A \egroup}=0A=0A\def\dosetupbnfgrammar[#1]%=0A {\getparame= ters[\??bnf][#1]%=0A \defterminal{\@@bnfterminalstart}{\@@bnfterminalstop= }%=0A \defnonterminal{\@@bnfnonterminalstart}{\@@bnfnonterminalstop}%=0A = \defcolon{\@@bnfcolon}%=0A \defsemicolon{\@@bnfsemicolon}%=0A \defper= iod{\@@bnfperiod}%=0A \defcomma{\@@bnfcomma}}=0A=0A\def\setupbnfgrammar%= =0A {\dosingleargument\dosetupbnfgrammar}=0A=0A\setupbnfgrammar=0A [\c!te= rminalstart=3D{\{\bf},=0A \c!terminalstop=3D{\}},=0A \c!nonterminalstar= t=3D{$\langle$},=0A \c!nonterminalstop=3D{$\rangle$},=0A \c!colon=3D{$\= rightarrow$},=0A \c!semicolon=3D{$|$},=0A \c!period=3D{},=0A \c!comma= =3D{}]=0A=0A\abbreviation{BNF}{Backus-Naur Form}=0A=0A\setupheadtext [\s!en= ] [\v!bnfgrammar=3D\BNF\ Grammar]=0A\setupheadtext [\s!en] [\v!bnfgrammars= =3D\BNF\ Grammars]=0A\setuplabeltext [\s!en] [\v!bnfgrammar=3D\BNF\ Grammar= ]=0A=0A\definefloat=0A [\v!bnfgrammar]=0A [\v!bnfgrammars]=0A=0A\protect= \endinput=0A --Nq2Wo0NMKNjxTN9z--