-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_lang.sh
executable file
·62 lines (55 loc) · 1.06 KB
/
build_lang.sh
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
#!/bin/bash
if [ $3 == src/lang_rev.awk ]; then
cat > $1 <<-EOF
/*
* code automatically generated with make and build_lang.sh
*/
#ifndef LANG_REV_H
#define LANG_REV_H
#include "language.h"
static inline language_code
lang_from_str(const char *str)
{
switch (str[0] << 8 | str[1])
{
EOF
sort $2 | awk -f $3 >> $1
cat >> $1 <<-EOF
default: elog(ERROR, "unknown language type: %s", str);
}
};
#endif
EOF
elif [ $3 == src/lang_fwd.awk ]; then
cat > $1 <<-EOF
/*
* code automatically generated with make and build_lang.sh
*/
#ifndef LANG_FWD_H
#define LANG_FWD_H
#include "language.h"
static inline char *
create_string(const char *chars)
{
char *str = (char *) palloc(3 * sizeof(char));
memcpy(str, chars, 2 * sizeof(char));
str[2] = '\0';
return str;
}
static inline char *
language_to_str(language_code c)
{
switch (c)
{
EOF
sort -k 3 -n $2 | awk -f $3 >> $1
cat >> $1 <<-EOF
default: elog(ERROR, "internal language representation unknown: %u", c);
}
}
#endif
EOF
else
echo "unknown awk command"
exit 1
fi