Re: additional regular expression operators

torbenm@pc-003.diku.dk (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen)
Tue, 14 Apr 2009 17:41:37 +0200

          From comp.compilers

Related articles
additional regular expression operators rpboland@gmail.com (Ralph Boland) (2009-03-29)
Re: additional regular expression operators m.helvensteijn@gmail.com (2009-03-30)
Re: additional regular expression operators zaimoni@zaimoni.com (2009-03-30)
Re: additional regular expression operators haberg_20080406@math.su.se (Hans Aberg) (2009-03-30)
Re: additional regular expression operators torbenm@pc-003.diku.dk (2009-03-31)
Re: additional regular expression operators rpboland@gmail.com (Ralph Boland) (2009-03-31)
Re: additional regular expression operators torbenm@pc-003.diku.dk (2009-04-14)
Re: additional regular expression operators zayenz@gmail.com (MZL) (2009-04-15)
Re: additional regular expression operators anton@mips.complang.tuwien.ac.at (2009-04-16)
Re: additional regular expression operators gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-04-16)
Re: additional regular expression operators torbenm@pc-003.diku.dk (2009-04-17)
Re: additional regular expression operators mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2009-04-17)
| List of all articles for this month |

From: torbenm@pc-003.diku.dk (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen)
Newsgroups: comp.compilers
Date: Tue, 14 Apr 2009 17:41:37 +0200
Organization: Department of Computer Science, University of Copenhagen
References: 09-03-111 09-03-123 09-04-001
Keywords: lex
Posted-Date: 16 Apr 2009 12:29:29 EDT

Ralph Boland <rpboland@gmail.com> writes:


> On Mar 31, 5:30 am, torb...@pc-003.diku.dk (Torben Fgidius Mogensen)
> wrote:
>> Ralph Boland <rpbol...@gmail.com> writes:
>> > I plan to provide support for at least three additional
>> > unary operators to the standard three (?,*, and +)
>>
>> > R! :does not accept the empty string but otherwise
>> > accepts every expression that R does. Very useful.
>>
>> > R~ :accepts exactly the set of strings that R does not accept.
>> > note that R = R~~.
>>
>> > R% : equivalent to the string (R~)R
>>
>> I can see the usefulness of the first two, but not really the third.
>> Do you have an example?
>
> It's useful in pattern matching where we want to find the first
> occurrence of pattern R.


I can't see how, unless your general rule is that a regular expression
finds the shortest prefix of the string that matches the expression.
The usual rule is to find the longest prefix or to find the first
occurrence (i.e., not necessarily a prefix) that does.


> It is also useful in scanners where we have comments.
> If a comment starts with <: and ends with :> the
> definition of a comment would be:
> <:(:>)%.


I don't think this will work. Assume the string is


        <:abc:>:>


This will match the regexp, as abc:> matches (:>)~.


Torben



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.