forked from vectorgraphics/asymptote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asy-list.pl
executable file
·106 lines (81 loc) · 1.57 KB
/
asy-list.pl
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
#!/usr/bin/env perl
#####
# asy-list.pl
#
# Build asy-keywords.el from list of asy global functions and variables
#
#####
open(keywords, "> asy-keywords.el") ||
die("Couldn't open asy-keywords.el for writing.");
print keywords <<END;
;;
;; This file is automatically generated by asy-list.pl.
;; Changes will be overwritten.
;;
(defvar asy-keywords-version "$ARGV[1]")
END
sub add {
print keywords $_[0]." ";
}
sub openlist {
open(asylist, $ARGV[0]) || die("Couldn't open $ARGV[0]");
}
print keywords <<END;
(defvar asy-keyword-name '(
END
open(camp, "camp.l") || die("Couldn't open camp.l");
# Search for the %% separator, after which the definitions start.
while (<camp>) {
if (/^%%\s*$/) {
last; # Break out of the loop.
}
}
while (<camp>) {
if (/^%%\s*$/) {
last; # A second %% indicates the end of definitions.
}
if (/^(\w+)\s*\{/) {
add($1);
}
}
openlist();
while (<asylist>) {
if (/^(\w*)[^ ]* (\w*)\(.*/) {
push @types, $1;
push @functions, $2;
}
if (/^([^ ]*) (\w*);/) {
push @variables, $2;
}
}
@saw{@types} = ();
@types = sort keys %saw;
undef %saw;
@saw{@functions} = ();
@functions = sort keys %saw;
undef %saw;
@saw{@variables} = ();
@variables = sort keys %saw;
undef %saw;
print keywords <<END;
))
(defvar asy-type-name '(
END
foreach(@types) {
print keywords $_ . " ";
}
print keywords <<END;
))
(defvar asy-function-name '(
END
foreach(@functions) {
print keywords $_ . " ";
}
print keywords <<END;
))
(defvar asy-variable-name '(
END
foreach(@variables) {
print keywords $_ . " ";
}
print keywords "))\n";