lua-users home
lua-l archive

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


Ideally in the "do it yourself" idea Lua is in, it would be possible to make this alternations to the parser/lexer from within in script code (including all other kind of syntactic sugar often asked)

Speaking of which, what happened to metalua?

On Mon, Mar 14, 2016 at 1:13 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> Unless I'm missing something, this wouldn't result in any ambiguous
> syntax. An identifier, followed by a . or :, followed by a keyword, is
> never valid syntax under current rules, so treating the keyword in
> that sequence of tokens as an identifier shouldn't cause problems.
>
> So I'm +1 on this. It would be nice to have the ability to do things
> like _G.end (or _ENV.end). Again, unless I'm missing something (which
> I very well might be given that I'm currently recovering from a cold
> that's screwing with my thinking a bit).

If not causing ambiguity is a good enough reason, why stop at reserved
words? We could as well add all the other tokens, too. None of them
cause ambiguities:

  _G.*  _G.%  _G.>=  _G.<  _G.==  _G.(  _G.]  _G:)

And it would be even easier to implement...

(For '.', '..', '...', and numbers, we would need to add a space,
like here: '_G. .'   _'G. ..'  '_G. ...'  '_G. 34')

-- Roberto