lua-users home
lua-l archive

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


2009/12/3 David Kastrup <dak@gnu.org>:
> If you say the latter, then you need to extend the precedence hierarchy
> of Lua by another level.  There are already 8 levels.
>
> Is this syntax extension worth introducing another precedence level?

Actually there is a shift/reduce conflict in the grammar since the expression
|x| x or y
can be parsed as:
(|x| x) or y
or
|x| (x or y)

But please note that for your example, there is no difference between
|x| x+y
and
|x| x or y
Since both '+' and 'or' are considered operators.

The answer is that once '|' args '|' is parsed Lua recursive descent
parser just look for an 'expr' and will eat (shift) everything that
looks as an expression. So something like
|x| x or y

will always be parsed as |x| (x or y) and no new precedence level has
been introduced.

Francesco