-
Notifications
You must be signed in to change notification settings - Fork 0
/
genh
executable file
·37 lines (31 loc) · 871 Bytes
/
genh
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
#!/usr/bin/env perl
use warnings;
use strict;
my ($include_guard) = shift @ARGV;
my $now = scalar localtime;
my $files = join("\n * ", @ARGV);
print <<"PREAMBLE";
#ifndef $include_guard
#define $include_guard
/*
Generated by $0 at $now, from
* $files
*/
PREAMBLE
while (<>) {
if (m/^\s*PRIMITIVE\s*\(\"[^"]+\",\s*[^,]+,\s*([^,]+),\s*[^,]+\s*\)\s*\{/) {
print "void $1 ();\n";
}
elsif (m/^\s*VARIABLE\s*\(([^,]+),\s*[^,]+,\s*[^,]+,\s*[^,]+\s*\)\s*;/) {
print "extern cell * const var_$1;\n";
}
elsif (m/^\s*CONSTANT\s*\(([^,]+),\s*[^,]+,\s*[^,]+,\s*[^,]+\s*\)\s*;/) {
print "extern const cell * const const_$1;\n";
}
elsif (m/^\s*READONLY\s*\(([^,]+),\s*[^,]+,\s*[^,]+,\s*[^,]+\s*\)\s*;/) {
print "void readonly_$1 ();\n";
}
}
print <<"POSTAMBLE";
#endif /* $include_guard */
POSTAMBLE