lua-users home
lua-l archive

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


On Mon, Apr 11, 2011 at 4:01 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> The second change lets the grammar writer refactor a non-terminal to a
>> definition without adding % to all of its uses.
>
> Can't you simply keep the non-terminal as a non-terminal, adding one new
> rule like this?
>
>  non-terminal -> %new-definition

This works, but it is like using module without package.seeall. :-)

>
>> The first change, when combined with the second, just lets Luma offer
>> _ as a predef for Lua whitespace (in the lexer sense) for the user's
>> grammars, which is useful in a lot of grammars and less obstrusive
>> than %space or %s.
>
> Several examples in LPeg use the symbols 'S' or 's' for whitespace; the
> specification for XML uses 'S'. They do not seem obstrusive. (You may
> prefer 's' to avoid hitting the shift key.)

I have written grammars with %s myself and do not mind using it, but
it is harder to ignore than _ when reading, using _ makes it look more
like EBNF without having to use a separate "lexical grammar".

> I see these changes as minor adjustments, and may even add them to LPeg
> (the "second" change is a little controversial); but to claim they add
> *much* more convenience seems to me a bit exaggerated.

I got carried away with the "much", I admit.

As I said, the syntax for definitions and non-terminals was the same
prior to LPEG 0.8. I understand why the %name syntax was introduced
for definitions, but did you make <name> (and, with 0.10, name) be
just for non-terminals to avoid having a definition shadow a
production?

> -- Roberto
>

--
Fabio