-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathjava.lua
More file actions
147 lines (120 loc) · 3.71 KB
/
java.lua
File metadata and controls
147 lines (120 loc) · 3.71 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
highlight("package", "reserved")
highlight("import", "reserved")
highlight("public", "reserved")
highlight("private", "reserved")
highlight("protected", "reserved")
highlight("class", "reserved")
highlight("enum", "reserved")
highlight("record", "reserved")
highlight("interface", "reserved")
highlight("extends", "reserved")
highlight("implements", "reserved")
highlight("module", "reserved")
highlight("super", "reserved")
highlight("this", "reserved")
highlight("void", "reserved")
highlight("boolean", "reserved")
highlight("int", "reserved")
highlight("double", "reserved")
highlight("long", "reserved")
highlight("float", "reserved")
highlight("char", "reserved")
highlight("byte", "reserved")
highlight("short", "reserved")
-- which mf actually uses these
highlight("const", "reserved")
highlight("goto", "reserved")
highlight("strictfp", "reserved")
highlight("instanceof", "reserved")
highlight("native", "reserved")
highlight("new", "reserved")
highlight("return", "reserved")
highlight("final", "reserved")
highlight("static", "reserved")
highlight("transient", "reserved")
highlight("volatile", "reserved")
highlight_region("\"", "\"", "string", true)
highlight_region("//", "", "comments", true)
highlight_region("/*", "*/", "comments")
highlight_region("@", "", "annotation", true)
highlight("if", "reserved")
highlight("else", "reserved")
highlight("do", "reserved")
highlight("while", "reserved")
highlight("for", "reserved")
highlight("continue", "reserved")
highlight("default", "reserved")
highlight("break", "reserved")
highlight("switch", "reserved")
highlight("case", "reserved")
highlight("try", "reserved")
highlight("catch", "reserved")
highlight("finally", "reserved")
highlight("throw", "reserved")
highlight("throws", "reserved")
highlight("false", "binary")
highlight("true", "binary")
highlight("null", "binary")
highlight("synchronized", "reserved")
highlight("assert", "reserved")
highlight("exports", "reserved")
highlight("module", "reserved")
highlight("non-sealed", "reserved")
highlight("open", "reserved")
highlight("opens", "reserved")
highlight("permits", "reserved")
highlight("provides", "reserved")
highlight("requires", "reserved")
highlight("sealed", "reserved")
highlight("to", "reserved")
highlight("transitive", "reserved")
highlight("uses", "reserved")
highlight("var", "reserved")
highlight("when", "reserved")
highlight("with", "reserved")
highlight("yield", "reserved")
--- Logical Operators
highlight("&&", "operator")
highlight("||", "operator")
highlight("!", "operator")
--- Bitwise Operators
highlight("&", "operator")
highlight("|", "operator")
highlight("^", "operator")
highlight("~", "operator")
highlight("<<", "operator")
highlight(">>", "operator")
add_comment("boiler plate alert!!!")
add_comment("public static volatile transient transitive synchronized class type language 🗣️🔥")
add_comment("another semicolon please")
add_comment("use a lambda you dumbass")
function detect_functions(content)
local functionNames = {}
for line in content:gmatch("[^\r\n]+") do
local pattern = "[%a_][%a%d_<>]*%s+([%a_][%a%d_]*)%s*%("
local functionName = line:match(pattern)
if functionName then
table.insert(functionNames, functionName);
end
end
return functionNames
end
function detect_variables(content)
local variable_names = {
"this",
"super",
"System",
"Object",
"Math",
"Thread",
"Runtime"
}
for line in content:gmatch("[^\r\n]+") do
local pattern = "%f[%a_][%a_][%a%d_<>]*%s+([%a_][%a%d_<>]*)%s*=%s*[^;]+;"
local match = line:match(pattern)
if match then
table.insert(variable_names, match)
end
end
return variable_names
end