keyword ​
Lua keyword helpers.
Usage ​
lua
kw = require "mods.keyword"
kw.iskeyword("local")) --> true
kw.isidentifier("hello_world") --> trueDependencies ​
Dependencies below are lazy-loaded 💤 on first access.
Functions ​
| Function | Description |
|---|---|
iskeyword | Return true when s is a reserved Lua keyword. |
isidentifier | Return true when s is a valid non-keyword Lua identifier. |
kwlist | Return Lua keywords as a mods.List. |
kwset | Return Lua keywords as a mods.Set. |
normalize_identifier | Normalize an input into a safe Lua identifier. |
iskeyword ​
Return true when s is a reserved Lua keyword.
lua
kw.iskeyword("function") --> true
kw.iskeyword("hello") --> falseisidentifier ​
Return true when s is a valid non-keyword Lua identifier.
lua
kw.isidentifier("hello_world") --> true
kw.isidentifier("local") --> falsekwlist ​
Return Lua keywords as a mods.List.
lua
kw.kwlist():contains("and") --> truekwset ​
Return Lua keywords as a mods.Set.
lua
kw.kwlset():contains("and") --> truenormalize_identifier ​
Normalize an input into a safe Lua identifier.
lua
kw.normalize_identifier(" 2 bad-name ") --> "_2_bad_name"