Email List: Xaustin-group-lX
[All Lists]

Re: RE-ASSOC: a question about the associativity of RE concatenation

To: Tom Lord <yyyy@xxxxxxxxxxx>
Subject: Re: RE-ASSOC: a question about the associativity of RE concatenation
From: <yyyyyyy@xxxxxxxx>
Date: Fri, 12 Apr 2002 10:59:54 -0400 (EDT)
Cc: <yyyyyy@xxxxxxxxxxx>, <yyyyyyyyyyyyyy@xxxxxxxxxxxxx>, <yyyyy@xxxxxxxxxxxxxx>, <yyyyy@xxxxxxxxxx>
On Fri, 12 Apr 2002, Tom Lord wrote:

> ... elided ...
> Suppose that /A/ matches some prefix of S leaving a non-empty suffix
> left-over.  Suppose that /(B)/ matches that suffix.  Then when
> matching /A(B)/ against S, /A/ matches just the same in both
> expressions.  The leftmost subpattern is satisfied with highest
> priority.  With right associativity, that nice, intuitive property is
> lost (as illustrated by examples I gave in an earlier message).
>
> The more I think about it, the less I think this is a purely
> theoretical consideration.  When developing a long, complex pattern -
> it's pretty natural for users to test it out in bits in pieces.  In
> other words, people will in fact write /A/, then write /(B)/, and then
> expect not to be surprised when forming /A(B)/.  Right-associativity
> will surprise them.

You are right. That is exactly how people test and debug REs.

Given purely practical considerations, it is clear that:

1) Implementations cannot be allowed to choose either right or left
associativity as that would leave users with no portable way of testing
the expressions. At least if users *know* it is right associative, they
can test the expression backwards.

2) Trying to convince users to debug REs backwards is a bad idea.

-- 
Eric Vought
Chief Technical Officer - QLUE Consulting, Inc.

yyyyyyy@xxxxxxxx toll-free: 888-771-3538  RTP area: 919-816-9901

<Prev in Thread] Current Thread [Next in Thread>