From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,13b4e394fcd91d4 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.68 with SMTP id nq4mr5416864pbc.2.1327722144186; Fri, 27 Jan 2012 19:42:24 -0800 (PST) MIME-Version: 1.0 Path: lh20ni232182pbb.0!nntp.google.com!news1.google.com!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!amsnews11.chello.com!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: OpenToken: Handling the empty word token Date: Fri, 27 Jan 2012 21:42:18 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <62121d9d-f208-4e78-a109-749742da14a6@h12g2000yqg.googlegroups.com> <1jvlv7i0tn14u.b5d2cwsqhl2h$.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1327722142 8302 69.95.181.76 (28 Jan 2012 03:42:22 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 28 Jan 2012 03:42:22 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-01-27T21:42:18-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:1jvlv7i0tn14u.b5d2cwsqhl2h$.dlg@40tude.net... > On Fri, 27 Jan 2012 08:22:12 -0800 (PST), mtrenkmann wrote: > >> Is there a way to instrument the parser to silently accept the epsilon >> token whenever it expects it without consuming a token from the lexer, >> or is it a common convention to translate each grammar into a epsilon- >> free representation? > > I use neither explicit grammars nor OpenToken, so it is possible that I > didn't really understand the problem you have. Like Dmitry, I don't use OpenToken, but I do use a LALR(1) parser generator (ours originates in a University of Wisconsin research project from the late 1970s). In all of the grammars I've seen, you don't write anything for an epsilon production; that's because you are matching nothing. But there is no problem in matching nothing, so long as your grammar generator is powerful enough (uses at least LALR(1) parsing, or perhaps LR(1) parsing). In that case, matching nothing works so long as the follow sets are disjoint (something that fails to be true periodically in our Ada grammar). For instance, here's the grammar for parameter modes from the Janus/Ada compiler grammar: mode ::= IN ## 93 | OUT ## 94 | IN OUT ## 95 | ## 198 Note that the last production is an epsilon production. The ## part gives an action number associated with the matching of that particular alternative of this production. The ## part also marks the end of the production (it's optional, and | also ends a production -- but it's required on the last alternative as the grammar of our grammar uses insignificant line endings like Ada does). I'd be surprised if OpenToken didn't have something similar; and if it doesn't, you probably need to upgrade to a better grammar generator. Randy.