-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze.tiny
37 lines (30 loc) · 968 Bytes
/
analyze.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
###############################################################
#
# Display all of the classes and functions defined in tiny.ps1
#
###############################################################
funcs = {}
classes = {}
comments = 0
tests = 0
other = 0
#
# Accumulate functions and classes; count comments
# and other lines.
#
readfile 'tiny.ps1' {
match it
| r/#T / -> tests += 1
| r/#.*$/ -> comments += 1
| r/class +([a-z]+)/:class -> classes[class[1]] = true
| r/^ *function +([a-z]+)/:func -> funcs [func[1]] = true
| -> other += 1
}
alert("Total lines in file: {0}",
comments + classes.Count + funcs .count + other)
alert("Total comments: $comments")
alert("Total tests: $tests")
alert("Total classes ${classes.Count}")
classes |> keys |> sort |> printlist
alert("Total functions ${funcs.Count}")
funcs |> keys |> sort |> printlist