lua-users home
lua-l archive

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


On Fri, Apr 15, 2011 at 10:47 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> [...]
>>
>> And, so, the <> became superfluous. So, maybe the % is superfluous too.
>> (But maybe I do not recall correctly...)
>
> The '%' is not gratuitous. The patch for Luma gives definitions
> priority over non terminals. This seems to me a big mistake; local names
> should always have priority over further ones.

I know, and had commented on this a couple emails back. :-) That is
why I though you split defs and non-terminals, so defs would no shadow
non-terminals (without extra work on the part of the RE compiler).

> If I write something like
>
>  p = re.compile([[p -> . p / '']], defs)
>
> I will have weird surprises if 'p' happens to be defined in 'defs'.
>
> We could ameliorate the problem by raising an error if a non-terminal
> is defined with the name of a definition, but this still seems wrong
> to me. A correct, stand-alone grammar could be made invalid depending
> of the definitions given in its compilation.
>
> (The patch also distinguishes between pre-definitions [that still need
> the '%'] and 'non-pre'definitions; this distinction also creates some
> confusion).

This was an oversight, not intentional.

> In my view, the correct think would be to give non-terminals priority
> over definitions; this is harder to implement, but not impossible.

For this patch I just wanted to duplicate the old behavior of re.lua,
as all the examples in the Luma tarfile depended on it. A solution for
the precedence problem is going to be tricky, because RE allows nested
grammars (and I am not even talking about having lexical scoping among
grammars).

> -- Roberto
>
>

--
Fabio Mascarenhas