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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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.222.71 with SMTP id qk7mr6468107pbc.1.1327948448216; Mon, 30 Jan 2012 10:34:08 -0800 (PST) Path: lh20ni241983pbb.0!nntp.google.com!news1.google.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: OpenToken: Handling the empty word token Date: Mon, 30 Jan 2012 19:34:06 +0100 Organization: cbb software GmbH Message-ID: <1r5s26c6dmfh2$.190wc38zc11v2.dlg@40tude.net> References: <62121d9d-f208-4e78-a109-749742da14a6@h12g2000yqg.googlegroups.com> <82k44cayui.fsf@stephe-leake.org> <7756ad67-4ce1-4fb8-a4a1-f8136815ac9b@p13g2000yqd.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: CNp+VBSYV+ysZXOiVRxJxw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-01-30T19:34:06+01:00 List-Id: On Mon, 30 Jan 2012 08:28:57 -0800 (PST), mtrenkmann wrote: > I am wondering if that behavior cannot be implemented in the table- > lookup procedure. That is when I call Action_For with an unexpected > token, while there is the epsilon as one of the expected tokens, then > this epsilon could be accepted automatically, the parser changes its > state accordingly, and the unexpected token is checked again. Don't > know if that is possible, since I am not yet familiar with the > internals of table-driven parsing. You have tables of token for states where there are alternatives. You match the source against the table: Get (Source, Statements_Table, Token, Got_It); if Got_It then -- One of the tokens has been matched case Token is when If_Token => Do_If; when For_Token => Do_For; when ... => ... end case; else -- Nothing matched, this is the "epsilon" choice ... end if; This is basically a recursive descent parser. You would also have to define a pair useful subprograms like Skip_Blanks, Get_Identifier, Get_Literal, Get_Keyword. The only difficult part is infix expressions. For these there are ready-to-use means, which match the expression evaluating it or producing a tree as byproduct. The problem as you described it just does not exist. You get the keyword, if it is not there, you do something in reaction. That is. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de