-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpossibleEdits.lua
More file actions
123 lines (115 loc) · 3.25 KB
/
possibleEdits.lua
File metadata and controls
123 lines (115 loc) · 3.25 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
--This is the lexer for string detector 1
local program = [[135 " Minecraft"]] --This is the program for now. Shush.
local tokens = {}
local function lex(code)
local check = 1
local endPoint = 1
local currentToken = ""
while #code >= endPoint do
local dataTypa
local charac = string.sub(code, endPoint, endPoint)
if charac == " " then
if type(tonumber(currentToken)) == "number" then
currentToken = currentToken.."n"
dataTypa = "number"
else
dataTypa = "id"
end
table.insert(tokens, {dataTypa,currentToken})
currentToken = ""
else
currentToken = currentToken..charac
end
if charac == "\"" then
if type(tonumber(currentToken)) == "number" then
currentToken = currentToken.."n"
dataTypa = "number"
else
dataTypa = "id"
end
table.insert(tokens, {dataTypa,currentToken})
charac = ""
currentToken = ""
local something = endPoint
while charac ~= "\"" and endPoint == something do
charac = string.sub(code, endPoint, endPoint)
print(charac)
currentToken = currentToken..charac
print(currentToken)
table.insert(tokens, {"string", currentToken})
endPoint = endPoint + 1
end
end
endPoint = endPoint + 1
end
if type(tonumber(currentToken)) == "number" then
currentToken = currentToken.."n"
dataTypa = "number"
else
dataTypa = "id"
end
table.insert(tokens, {dataTypa,currentToken})
while check < #code do
for i, v in pairs(tokens) do
if v[2] == " " or v[2] == "\"" and v[1] == "id" then
table.remove(tokens, i)
end
end
check = check + 1
end
end
lex(program)
for i, v in pairs(tokens) do
print(tostring(i)..": "..v[2].." is classified as a "..v[1])
end
--Same thing with a different twist
local program = [[135 "ackreik"]] --This is the program for now. Shush.
local tokens = {}
local function lex(code)
local check = 1
local endPoint = 1
local currentToken = ""
while #code >= endPoint do
local dataTypa
local charac = string.sub(code, endPoint, endPoint)
if charac == " " then
print(currentToken)
if string.sub(currentToken, 1, 1) == "\"" and string.sub(currentToken, #currentToken, #currentToken) == "\"" then
print(0)
currentToken = string.sub(currentToken, 2, #currentToken - 1)
table.insert(tokens, {"string", currentToken})
return "a"
end
if type(tonumber(currentToken)) == "number" then
currentToken = currentToken.."n"
dataTypa = "number"
else
dataTypa = "id"
end
table.insert(tokens, {dataTypa,currentToken})
currentToken = ""
else
currentToken = currentToken..charac
end
endPoint = endPoint + 1
end
if type(tonumber(currentToken)) == "number" then
currentToken = currentToken.."n"
dataTypa = "number"
else
dataTypa = "id"
end
table.insert(tokens, {dataTypa,currentToken})
while check < #code do
for i, v in pairs(tokens) do
if v[2] == " " then
table.remove(tokens, i)
end
end
check = check + 1
end
end
lex(program)
for i, v in pairs(tokens) do
print(tostring(i)..": "..v[2])
end