-
Notifications
You must be signed in to change notification settings - Fork 15
/
sdf2bgf
executable file
·64 lines (63 loc) · 2.44 KB
/
sdf2bgf
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
#!/bin/bash
# wiki: SDF2BGF
# Get our hands on basedir
LOCAL1=${PWD}
cd `dirname $0`
cd ../../topics/extraction/sdf
XTR=${PWD}
cd ${LOCAL1}
if [ $# -le 1 ]; then
echo "This extractor gives a BGF for a list of SDF modules"
echo "Usage: sdf2bgf <SDF-module> [<SDF-module> ...] <BGF-output>"
exit 1
elif [ -z `which asfe` ] || [ -z `which sglr` ] || [ -z `which unparsePT` ]; then
echo 'Need these tools in path: sglr, asfe, unparsePT.'
exit 2
else
# Build extractor if needed
cd ${XTR}
make build
cd ${LOCAL1}
echo "main(definition" > _.def
CX=1
for i in $* ; do
if [ $# -gt $CX ]; then
if [ ! -r $i ]; then
echo "Oops: $i not found or not readable."
exit 1
fi
cat $i >> _.def
CX=`expr $CX + 1`
else
echo ")" >> _.def
cat _.def | sglr -p ${XTR}/Main.tbl | asfe -e ${XTR}/Main.eqs | unparsePT > $i
# a fix for ->
perl -pi -w -e 's/strcon2chardata\(\"\-\>\"\)/\-\>/g;' $i
# a fix for =>
perl -pi -w -e 's/strcon2chardata\(\"\=\>"\)/\=\>/g;' $i
perl -pi -w -e "s/sqstrcon2chardata\(\'\=\>'\)/\=\>/g;" $i
# a fix for <:
perl -pi -w -e 's/strcon2chardata\(\"\<:\"\)/\<:/g;' $i
# a fix for <=
perl -pi -w -e 's/strcon2chardata\(\"\<\=\"\)/\<\=/g;' $i
perl -pi -w -e "s/sqstrcon2chardata\(\'\<\=\'\)/\<\=/g;" $i
# a fix for <<
perl -pi -w -e 's/strcon2chardata\(\"\<\<\"\)/\<\</g;' $i
# a fix for <<=
perl -pi -w -e 's/strcon2chardata\(\"\<\<\=\"\)/\<\<\=/g;' $i
# a fix for >>
perl -pi -w -e 's/strcon2chardata\(\"\>\>\"\)/\>\>/g;' $i
# a fix for &=
perl -pi -w -e 's/strcon2chardata\(\"\&\=\"\)/\&\=/g;' $i
# a fix for &&
perl -pi -w -e 's/strcon2chardata\(\"\&\&\"\)/\&\&/g;' $i
# a fix for >=
perl -pi -w -e 's/\<terminal\>\>\=\<\/terminal\>/\<terminal\>\>\=\<\/terminal\>/g;' $i
# a fix for >>=
perl -pi -w -e 's/\<terminal\>\>\>\=\<\/terminal\>/\<terminal\>\>\>\=\<\/terminal\>/g;' $i
# a fix for >>>
perl -pi -w -e 's/\<terminal\>strcon2chardata\(\"\>\>\>\"\)\<\/terminal\>/\<terminal\>\>\>\>\<\/terminal\>/g;' $i
fi
done
rm -f _.def
fi