blob: 3f18388bc53aee9e391e49b7a576f7375fc02a37 (
plain)
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
|
#!/usr/bin/env perl
#####
# opsymbols.pl
# Andy Hammerlindl 2010/06/01
#
# Extract mapping such as '+' --> SYM_PLUS from camp.l
#####
open(header, ">opsymbols.h") ||
die("Couldn't open opsymbols.h for writing");
print header <<END;
/*****
* This file is automatically generated by opsymbols.pl
* Changes will be overwritten.
*****/
// If the OPSYMBOL macro is not defined for a specific purpose, define it with
// the default purpose of using SYM_PLUS etc. as external pre-translated
// symbols.
#ifndef OPSYMBOL
#define OPSYMBOL(str, name) extern sym::symbol name
#endif
END
sub add {
print header "OPSYMBOL(\"".$_[0]."\", " . $_[1] . ");\n";
my $sym = $_[0];
my $name = $_[1];
print header <<END;
#ifndef PRESYM
#define $name sym::symbol::opTrans("$sym")
#endif
END
}
open(lexer, "camp.l") ||
die("Couldn't open camp.l");
while (<lexer>) {
if (m/^"(\S+)"\s*{\s*DEFSYMBOL\((\w+)\);/) {
add($1, $2);
}
if (m/^(\w+)\s*{\s*DEFSYMBOL\((\w+)\);/) {
add($1, $2);
}
}
|