-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.luau
More file actions
38 lines (36 loc) · 1.3 KB
/
example.luau
File metadata and controls
38 lines (36 loc) · 1.3 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
local lx = require("lexer")
local prs = require("parser")
local src = [[
local x: typeof(
(function(...)
local tbl = {
[((function() return "key" end)())] = {
nested = (function(a, b, c)
return {
value = if a > b then
(function() return c ^ 2 end)()
else
(if b < c then #"test" else -99),
computed = ({
[1 + 2 * 3] = function(self)
return self.x or self.y
end,
data = `{tostring(math.sqrt(16))} items`
})[4],
chain = workspace:GetService("Players"):GetPlayers()[1].Name
}
end)(1, 2, 3),
array = {1, 2, (function() return {...} end)(4, 5, 6)}
},
[(true and "active" or "inactive")] = ((-#{1,2,3} * 2 + #"hello") ^ 2) % 10
}
return tbl[(function() return "key" end)()].nested.value
end)(...)
) = 42
]]
local tokenised = lx.tokenize(src)
local parsed = prs.parse(tokenised)
print(tokenised)
print("-----------------------------")
print(parsed)
print("-----------------------------")