-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmkfunctions.bas
More file actions
89 lines (78 loc) · 1.56 KB
/
mkfunctions.bas
File metadata and controls
89 lines (78 loc) · 1.56 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
rem
rem generate functions.json for mkskeleton.bas
rem
rem from input generated with:
rem clang -Xclang -dump-tokens raylib/src/raylib.h 2>&1 | awk -F"'" '/identifier|l_paren|r_paren|semi|void/ {print $2}' > functions.tokens
rem
tload "functions.tokens", s
const len_s = len(s) - 1
const states = ["init", "name", "arg", "l_paren", "r_paren"]
funcs = []
subs = []
names = {}
sub reset
state = "init"
name = ""
args = []
is_func = true
end
sub mk_item
if (names[name] == 0) then
local item
item.name = name
item.args = args
if (is_func) then
funcs << item
else
subs << item
endif
names[name] = name
endif
end
sub process
local i, ch, parens
for i = 0 to len_s
select case s[i]
case "("
parens++
state = "l_paren"
case ")"
parens--
if (parens == 0) then state = "r_paren"
case ";"
mk_item
reset
parens = 0
case "void"
if (state == "init") then
is_func = false
endif
case else
if (state = "l_paren") then
ch = mid(s[i], 1, 1)
if (ch > "Z") then
'ignore class name
select case s[i]
case "false", "true", "bool"
case else
args << s[i]
end select
endif
else
name = s[i]
endif
end select
next i
end
func cmpFunc(l, r)
local f1 = lower(l.name)
local f2 = lower(r.name)
return iff(f1 == f2, 0, iff(f1 > f2, 1, -1))
end
reset
process
sort funcs use cmpFunc(x,y)
sort subs use cmpFunc(x,y)
out.func = funcs
out.sub = subs
print out