Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.lightlink.com!news.iecc.com!lnews.iecc.com!nerds-end From: glen herrmannsfeldt Newsgroups: comp.compilers Subject: Re: coupling LALR with a scanner? Date: Mon, 3 Oct 2011 21:08:39 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 29 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <11-10-008@comp.compilers> References: <11-07-013@comp.compilers> <11-07-015@comp.compilers> <11-07-018@comp.compilers> <11-08-004@comp.compilers> <11-09-016@comp.compilers> <11-09-017@comp.compilers> <11-09-022@comp.compilers> <11-09-023@comp.compilers> <11-10-003@comp.compilers> NNTP-Posting-Host: lnews.iecc.com X-Trace: gal.iecc.com 1317844048 99788 64.57.183.34 (5 Oct 2011 19:47:28 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Wed, 5 Oct 2011 19:47:28 +0000 (UTC) Keywords: parse Posted-Date: 05 Oct 2011 15:47:28 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: x330-a1.tempe.blueboxinc.net comp.compilers:290 Chris F Clark wrote: > I have come to this discussion a little late and may have missed some > of the conversation, so excuse me if I say some things which are > obvious and have been discussed before. (snip) > However, and here I think we come to the crux of the discussion, can a > scannerless system disambiguate the potentially ambiguous use of / as > a division operator and the start of a regular expression? I would > argue that if the system is LR(k) for some finite k and the use of > regular expressions is not restricted to some narrow (left, preceding) > context (e.g. as in Perl where regular expressions are part of only > specific operations like m/regex/ and ~=/regex/ (forgive me if my Perl > is a bit rusty)), then the answer is no. I could be completely missing the point, but it seems to me that you don't have to restrict such RE to a narrow context as long as the context isn't one where a division operator is allowed. Division usually requires a preceding operand. In the contexts I would expect a regular expression it would be either preceded by an operator or be the beginning of an expression. In writing AWK programs, where there are functions that take RE as operands, I normally put then in quotes (") instead of slashes, as it seems more obvious in the context. (A variable with the appropriate value also works.) -- glen