lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Look away for a day and my reply has spawned an entire debate, which for
the most part was resolved without my input. Back on the original topic,
I actually enjoy the vibe of lua-l, but maybe it's just me. ;)

On 1/26/2011 7:14 AM, Tony Finch wrote:
> On Wed, 26 Jan 2011, Peter Cawley wrote:
>> On Wed, Jan 26, 2011 at 4:21 AM, Miles Bader <miles@gnu.org> wrote:
>>> Hmm, still, his use of "recursive" doesn't seem to make any sense...
>>
>> I think his point was that the definition of the class of regular
>> expressions is recursive,

Yes, that's all I meant. Sorry that my words were not well chosen, and
thanks for clarifying them. :)

> Yes. That is, the syntax of regular expressions themselves is recursive,
> but regular expressions cannot be used to parse recursive syntaxes. So
> you can't use a regex to parse a regex.

Agreed.

> (Unless, like Perl, your regexes are so enormously distended that they are
> well beyond being regular.)

Something I noticed as I was reading the pattern docs for my post is
that Lua adds one thing to patterns that I've not seen in regular
expressions that does allow you to parse nested brackets:

----
%bxy, where x and y are two distinct characters; such item matches
strings that start with x, end with y, and where the x and y are
balanced. This means that, if one reads the string from left to right,
counting +1 for an x and -1 for a y, the ending y is the first y where
the count reaches 0. For instance, the item %b() matches expressions
with balanced parentheses.
----

I hadn't run across that before, and it's cool. As Tony mentions, Perl
has a LOT of extensions, and I don't care enough to check, but I
wouldn't be surprised if it does support something similar. But as far
as I'm concerned, what "grep" accepts is the canonical "regular
expression", and I'm sure grep doesn't support that. Another reason why
Lua is just more awesome. ;)

Tim