lua-users home
lua-l archive

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


On Fri, Apr 25, 2014 at 5:09 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:

> The point of my earlier remark, that 'end' etc is already caught by the
> lexer at the same stage as two-character operators, before the
> parser itself gets a chance, was precisely to emphasize that it would
> be a major re-engineering effort.

I am not too familiar with the lexer, so I may be quite wrong -- I
couldn't find an easy way to look at the last token consumed.  Instead
of reworking it to allow for look-behinds, one could add a boolean in
LexState to say if we just consumed a '.' -- not .. or ...  The next
time llex() is called to test if the next letter is part of an
identifier or reserved word it could test and flip this boolean, while
going the route of the identifier.  I don't think this would be a very
large change, it would just be worth arguing if it merits changing
LexState.  Anyway, that's how I think it could be done. :>

http://www.lua.org/source/5.2/llex.h.html#LexState
http://www.lua.org/source/5.2/llex.c.html#llex