lua-users home
lua-l archive

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

Rici Lake <> wrote:

> Sorry, that came out much snottier than I intended.

No offense taken. You just stated the obvious.

> For example, rather than make 'continue' a actual keyword in
> the lexer, you can leave it as a TK_NAME and do a special case
> recognition in the parser. It only needs to be checked when a
> statement is expected, and since it must be a block ender, it can
> only be followed by 'end', 'else'. 'elseif', 'until' and ';'.

I thought about that possibility but decided not to go down that route,
mainly because I wanted to minimise the local changes I would need to
apply once a new version of lua comes out.

I am still experimenting with these additional features anyway: perhaps
I change keywords or find another way. One rather sketchy idea would be
to dynamically switch the relevant parser bits between full lua
compatibility and extensions enabled. In this way I could use external
modules and still switch on extended features in my own code. One big
problem with that would be source code generated on the fly. We'll see.

In the end I am pragmatic: if a feature is nice but too troublesome to
implement (or maintain) I'll skip it. And for the time being poking
around the compiler internals does provide good fun and some insights.

> Looked at from another perspective, the use of barewords as
> table keys is completely syntactically separate from their
> use as keywords.

Indeed. I found that slightly irritating but what the heck. Lexer and
parser are such nice and (relatively) simple beasts...