1 |
#!/bin/sh |
#!/bin/sh |
2 |
# |
# |
3 |
# Generates the LSCP parser's C++ source files (src/network/lscpparser.cpp and |
# Generates the instrument script parser's C++ source files |
4 |
# src/network/lscpsymbols.h) according to the LSCP (BNF) grammar definition |
# (parser.h, parser.cpp and scanner.cpp in and src/scriptvm/) according to the |
5 |
# given by src/network/lscp.y |
# instrument script (BNF) grammar definition given by src/scriptvm/parser.y and |
6 |
|
# the terminal symbol scanner/lexer defintion given by src/scriptvm/scanner.l |
7 |
|
|
8 |
SCRIPTS_DIR=`dirname $0` |
SCRIPTS_DIR=`dirname $0` |
9 |
NETWORK_SRC_DIR="$SCRIPTS_DIR/../src/network" |
PARSER_SRC_DIR="$SCRIPTS_DIR/../src/scriptvm" |
10 |
|
|
11 |
|
echo -n "Searching for lexer and parser generator..." |
12 |
|
|
13 |
|
LEX_CMD=NONE |
14 |
|
if which "flex" > /dev/null; then |
15 |
|
LEX_CMD=`which flex` |
16 |
|
elif which "lex" > /dev/null; then |
17 |
|
LEX_CMD=`which lex` |
18 |
|
else |
19 |
|
echo "Error: You need lex (or flex) to generate the instrument script parser !" |
20 |
|
exit -1 |
21 |
|
fi |
22 |
|
|
|
echo -n "Searching for a parser generator..." |
|
23 |
YACC_CMD=NONE |
YACC_CMD=NONE |
24 |
if which "bison" > /dev/null; then |
if which "bison" > /dev/null; then |
25 |
YACC_CMD="`which bison` -y" |
YACC_CMD="`which bison` -y" |
26 |
elif which "yacc" > /dev/null; then |
elif which "yacc" > /dev/null; then |
27 |
YACC_CMD=`which yacc` |
YACC_CMD=`which yacc` |
28 |
else |
else |
29 |
echo "Error: You need yacc (or bison) to generate the LSCP parser !" |
echo "Error: You need yacc (or bison) to generate the instrument script parser !" |
30 |
exit -1 |
exit -1 |
31 |
fi |
fi |
|
echo "OK ($YACC_CMD)" |
|
32 |
|
|
33 |
echo "Generating LSCP parser..." |
echo "OK ($LEX_CMD, $YACC_CMD)" |
34 |
|
|
35 |
|
echo -n "Generating instrument script parser ... " |
36 |
( |
( |
37 |
cd $NETWORK_SRC_DIR |
cd $PARSER_SRC_DIR |
|
$YACC_CMD -d lscp.y |
|
|
$YACC_CMD lscp.y |
|
|
mv -f y.tab.h lscpsymbols.h |
|
|
mv -f y.tab.c lscpparser.cpp |
|
|
) |
|
|
echo "Done" |
|
38 |
|
|
39 |
echo -n "Updating Documentation/lscp.xml..." |
$LEX_CMD scanner.l |
40 |
(cd $SCRIPTS_DIR && ./update_grammar.pl) |
#mv -f lex.yy.c scanner.cpp |
41 |
echo "Done" |
mv -f lex.InstrScript_.c scanner.cpp |
42 |
|
|
43 |
echo -n "Generating src/network/lscp_shell_reference.cpp..." |
$YACC_CMD -d parser.y |
44 |
(cd $SCRIPTS_DIR && ./generate_lscp_shell_reference.pl) |
$YACC_CMD parser.y |
45 |
|
mv -f y.tab.h parser.h |
46 |
|
mv -f y.tab.c parser.cpp |
47 |
|
) |
48 |
echo "Done" |
echo "Done" |