With this code:
for n in pairs(_G) do print(n) end
I print the names of all global variables defined in the current environment.
Is there any way to print all Lua keywords (and
,break
,do
,else
,elseif
,end
,false
,for
,function
,if
,in
,local
,nil
,not
,or
,repeat
,return
,then
,true
,until
,while
)?
No, as reserved keywords don't correspond to any objects in memory - they only exists in parser. See manual for each version for full list, typicaly under "Lexical Conventions". For example for Lua 5.1 it is located at http://www.lua.org/manual/5.1/manual.html#2.1