-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcreatekwlists.jl
160 lines (122 loc) · 4.17 KB
/
createkwlists.jl
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
148
149
150
151
152
153
154
155
156
157
158
159
160
#clearconsole()
cd( dirname( @__FILE__()))
using DataStructures: SortedSet
using REPL.REPLCompletions
modulelist = [
# Core modules
"Core","Core.Compiler", "Core.IR", "Core.Intrinsics",
# Base modules
"Base", "Base.Broadcast", "Base.Docs", "Base.GC", "Base.Iterators", "Base.Libc",
"Base.MathConstants", "Base.Meta", "Base.StackTraces", "Base.Sys",
"Base.Threads",
# modules of the Standard Library
"Artifacts", "Base64", "CRC32c", "Dates", "DelimitedFiles", "Distributed",
"FileWatching", "Downloads", #"Future",
"InteractiveUtils", "LazyArtifacts", "LibGit2", "Libdl", "LinearAlgebra",
"Logging", "Markdown", "Mmap", "Pkg", "Printf", "Profile", "REPL", "Random",
"SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays",
"SuiteSparse", "Statistics", "SuiteSparse", "TOML", "Test", "UUIDs", "Unicode"
]
keywords, literals = SortedSet{String}(), SortedSet{String}()
builtins, macros = SortedSet{String}(), SortedSet{String}()
functions, functions! = SortedSet{String}(), SortedSet{String}()
vurest, allmod = SortedSet{String}(), SortedSet{String}()
strprefixes = SortedSet{String}()
# keywords
for kw in REPLCompletions.sorted_keywords
push!( keywords, kw)
end
union!(keywords, ["in", "isa", "where"])
# literals, built-ins, macros
for modstr ∈ modulelist
eval( Meta.parse( string( "using ", modstr))) # loading current module
for nsymb in names( eval( Meta.parse(modstr)), all=false)
#try
nstr = string( nsymb)
neval = eval( nsymb)
push!( allmod, nstr)
# literals
if !(neval isa Function || neval isa Type || neval isa Module)
push!( literals, nstr)
# built-ins
elseif neval isa Type
push!( builtins, nstr)
# macros
elseif neval isa Function && nstr[1] == '@'
push!( macros, nstr)
# functions
elseif neval isa Function
push!( functions, nstr)
if nstr[end] == '!'
push!( functions!, nstr)
end
# very unimportant rest
else
push!( vurest, nstr)
end
#catch
#end
end
end
# true and false are supposed to be displayed
# like literals and not keywords
setdiff!( keywords, ["true", "false"])
union!( literals, ["true", "false"])
# remove operators from the functions list
oplist = ["=>", "!", "!=", "!==", "%", "&", "'", "*", "+", "-", "/", "//", ":",
"<", "<:", "<<", "<=", "==", "===", ">", ">:", ">=", ">>", ">>>", "\\", "^",
"|", "|>", "~", "×", "÷", "∈", "∉", "∋", "∌", "∘", "√", "∛", "∩", "∪", "≈", "≉",
"≠", "≡", "≢", "≤", "≥", "⊆", "⊇", "⊈", "⊉", "⊊", "⊋", "⊻", "⋅"]
setdiff!( builtins, oplist)
setdiff!( functions, oplist)
setdiff!( functions!, oplist)
union!( vurest, oplist)
# string prefixes
replc = REPLCompletions.completions("", 0)[1]
for name ∈ replc
#try
if name isa REPLCompletions.ModuleCompletion
m = name.mod
if occursin( "\"", m)
push!( strprefixes, m)
end
end
#catch
#end
end
function PrintList( list, listname)
println( listname * ":")
curlength = 0
for el ∈ list
if curlength + length(el) + 1 ≥ 80
print("%\n")
curlength = 0
end
print( el, ",")
curlength = curlength + length( el) + 1
end
println( "\n")
end
function PrintLiterates( list)
println( "julia's functions ending with '!'")
curlength = 0
for el ∈ list
mod_el = "{$(el)}{{\\funcc{$(el)}}}{$(length(el))}"
if curlength + length(mod_el) > 80
print("\n")
curlength = 0
end
print( mod_el, " ")
curlength = curlength + length( mod_el) + 1
end
println( "\n")
end
# printing all lists
PrintList( keywords, "KEYWORDS")
PrintList( literals, "LITERALS")
PrintList( builtins, "BUILT-INS")
PrintList( macros, "MACROS")
PrintList( functions, "FUNCTIONS")
PrintList( strprefixes, "STRING PREFIXES")
PrintList( vurest, "VERY UNIMPORTANT REST")
PrintLiterates( functions!)