-
Notifications
You must be signed in to change notification settings - Fork 93
/
asy-list.pl
113 lines (88 loc) · 1.68 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
106
107
108
109
110
111
112
113
#!/usr/bin/env perl
#####
# asy-list.pl
#
# Build asy-keywords.el from list of asy global functions and variables
#
#####
use strict;
use warnings;
open(my $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]." ";
}
my $asylist;
sub openlist {
open($asylist, $ARGV[0]) || die("Couldn't open $ARGV[0]");
}
print $keywords <<END;
(defvar asy-keyword-name '(
END
open(my $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();
my @types;
my @functions;
my @variables;
while (<$asylist>) {
if (/^(\w*)[^ ]* (\w*)\(.*/) {
push @types, $1;
push @functions, $2;
}
if (/^([^ ]*) (\w*);/) {
push @variables, $2;
}
}
my %saw;
@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";