-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.luau
More file actions
44 lines (36 loc) · 1.04 KB
/
tokenizer.luau
File metadata and controls
44 lines (36 loc) · 1.04 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
-- made by SirKingBinx
-- (C) 2023 - 2026 bedroom.rbxl
local tokenizer = {}
local function either(T: any) return tostring(T) or T end
-- Used in the tokenizer to construct tables.
-- @param T: table to package
-- @return string Tokenized version of T
function tokenizer.construct(T: any): string
local result: string = ""
if typeof(T) == "table" then
for index: any, item: any in T do
if result == "" then
result = string.format("%s:%s", either(index), either(item))
else
result = string.format("%s;%s:%s", result, either(index), either(item))
end
end
else
warn(string.format("Empty or unindexable table (Skipped parsing) [mem:%s]", T or "nil"))
-- maybe fixed i got no idea
result = ""
end
return result
end
-- Deconstruct S
-- @param S: string
-- @return table Table representing S
function tokenizer.deconstruct(S: string)
local result = {}
local eacharg = string.split(S, ";")
for idx: number, item: string in eacharg do
local temp = string.split(item, ":")
result[temp[1]] = temp[2]
end
end
return tokenizer