I\'d like to modify the lua 5.2 source code to allow for an optional \"global\" keyword to precede global variable declarations. Has any done this or does anyone know how to do
See this discussion for details and a proposed patch (against 5.3): http://lua.2524044.n2.nabble.com/Say-No-to-global-by-default-summary-of-the-discussion-td7683658.html. It uses a different (non-keyword based) approach, but should be a good starting point.
Figured it out. First I appended a new token TK_GLOBAL to the end of the RESERVED enum.
Then in luaX_init() I added...
ts = luaS_new(L, "global");
luaS_fix(ts);
ts->tsv.reserved = cast_byte(TK_GLOBAL+1-FIRST_RESERVED);
And finally in the statement() function I added...
case TK_GLOBAL:
luaX_next(ls);
break;
As far as I can tell it works. Hopefully it's safe.