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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6d9eb594a33cb947 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-30 22:30:42 PST Path: supernews.google.com!sn-xit-02!supernews.com!sienna.impulse.net!63.208.208.143.MISMATCH!feed2.onemain.com!feed1.onemain.com!newsfeed2.earthlink.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!hermes.visi.com!news-out.visi.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Robert Dewar Newsgroups: comp.lang.ada Subject: Re: very specific question on Ada syntax Date: Wed, 31 Jan 2001 06:16:55 GMT Organization: Deja.com Message-ID: <958akk$l11$1@nnrp1.deja.com> References: <956vav$e7q$1@nnrp1.deja.com> <9573th$isv$1@nnrp1.deja.com> NNTP-Posting-Host: 205.232.38.14 X-Article-Creation-Date: Wed Jan 31 06:16:55 2001 GMT X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; U) X-Http-Proxy: 1.0 x54.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 X-MyDeja-Info: XMYDJUIDrobert_dewar Xref: supernews.google.com comp.lang.ada:4741 Date: 2001-01-31T06:16:55+00:00 List-Id: In article <9573th$isv$1@nnrp1.deja.com>, Ted Dennison wrote: > To the best of my knowledge, flex has no "last token" > function in its API. It can do *character* context, but not > token context. Thus to properly handle this situation with > lex, you'd have to hack it in manually with inserted C code > (most likely by passing info back from the parser). That's not the way I would do it at all. I would do it the same way that the GNAT lexer does things, which is to keep a global variable which remembers the previous token. That's useful for posting error messages anyway. There is absolutely NO problem in coding this in lex, remember that in lex, the whole idea is that each recognized token causes the execution of "inserted C code", this C code is not a hack, it is the essence of how flex works. I definitely would NOT do it by passing information back from the parser. See scans.ads and the entry to scn.adb in the GNAT sources for details on how this is done in GNAT. The issue of whether the lexer is written by hand or generated by flex is quite irrelevant in considering how to handle this situation. > > I just checked the Ada95 lex spec available from the AdaIC site > (http://www.adaic.org/standards/95lrm_rat/lexer9x.l > ). It indeed contains no context information in the token definitions, > and thus should have the same problem. The relevent entries are: > ------------------------------------------- > "'" return(TIC); > "'"."'" return(char_lit); > ------------------------------------------- > > -- > T.E.D. > > http://www.telepath.com/~dennison/Ted/TED.html > > Sent via Deja.com > http://www.deja.com/ > Sent via Deja.com http://www.deja.com/