-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseall.tiny
43 lines (35 loc) · 1.24 KB
/
parseall.tiny
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
############################################################
#
# A script to parse all of the Tiny files in a directory tree.
#
############################################################
println('Parsing all of the tiny files in this directory')
funcs = {}
variables = {}
ls '*.tiny' {rec:true}
|> foreach {
name = it.fullname
println(name)
try {
time {
tree = parsefile(name)
filevars = {}
# Use the visitor to extract all of the functions and variables used in a script.
tree.visit{ n ->
match n
| [<FunctionCall>] -> funcs[n.name] += 1
| [<variable>] -> {
filevars[n.name] += 1
variables[n.name] += 1
}
}
# Print out all of the variables used in the script.
warn("File variables: " + keys(filevars))
}
}
catch { }
}
alert("functions called by all scripts")
funcs |> sortdescending{it.value} |> foreach {info "${it.key} (${it.value})"}
alert("variables referenced in all scripts:")
variables |> sortdescending{it.value} |> println