-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkeyword.d.lua
More file actions
85 lines (78 loc) · 1.76 KB
/
Copy pathkeyword.d.lua
File metadata and controls
85 lines (78 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---@meta _
---
---Helpers for Lua keywords and identifiers.
---
---## Usage
---
---```lua
---kw = mods.keyword
---
---kw.iskeyword("local")) --> true
---kw.isidentifier("hello_world") --> true
---```
---
---@class mods.keyword
local M = {}
---
---Return `true` when `v` is a reserved Lua keyword.
---
---```lua
---kw.iskeyword("function") --> true
---kw.iskeyword("hello") --> false
---```
---
---@section Predicates
---@param v any Value to validate.
---@return boolean isKeyword Whether the check succeeds.
---@nodiscard
function M.iskeyword(v) end
---
---Return `true` when `v` is a valid non-keyword Lua identifier.
---
---```lua
---kw.isidentifier("hello_world") --> true
---kw.isidentifier("local") --> false
---```
---
---@section Predicates
---@param v any Value to validate.
---@return boolean isIdentifier Whether the check succeeds.
---@nodiscard
function M.isidentifier(v) end
---
---Return Lua keywords as a `mods.List`.
---
---```lua
---kw.kwlist():contains("and") --> true
---kw.kwlist():contains("global") --> true -- Lua 5.5+
---```
---
---@section Collections
---@return mods.List<string> words List of Lua keywords.
---@nodiscard
function M.kwlist() end
---
---Return Lua keywords as a `mods.Set`.
---
---```lua
---kw.kwlset():contains("and") --> true
---kw.kwlset():contains("global") --> true -- Lua 5.5+
---```
---
---@section Collections
---@return mods.Set<string> words Set of Lua keywords.
---@nodiscard
function M.kwset() end
---
---Normalize an input into a safe Lua identifier.
---
---```lua
---kw.normalize_identifier(" 2 bad-name ") --> "_2_bad_name"
---```
---
---@section Normalization
---@param s string Input string.
---@return string identifier Normalized Lua identifier.
---@nodiscard
function M.normalize_identifier(s) end
return M