--- linuxsampler/trunk/scripts/generate_parser.sh 2014/05/24 16:01:58 2580 +++ linuxsampler/trunk/scripts/generate_instrument_script_parser.sh 2014/05/30 12:48:05 2581 @@ -1,38 +1,48 @@ #!/bin/sh # -# Generates the LSCP parser's C++ source files (src/network/lscpparser.cpp and -# src/network/lscpsymbols.h) according to the LSCP (BNF) grammar definition -# given by src/network/lscp.y +# Generates the instrument script parser's C++ source files +# (parser.h, parser.cpp and scanner.cpp in and src/scriptvm/) according to the +# instrument script (BNF) grammar definition given by src/scriptvm/parser.y and +# the terminal symbol scanner/lexer defintion given by src/scriptvm/scanner.l SCRIPTS_DIR=`dirname $0` -NETWORK_SRC_DIR="$SCRIPTS_DIR/../src/network" +PARSER_SRC_DIR="$SCRIPTS_DIR/../src/scriptvm" + +echo -n "Searching for lexer and parser generator..." + +LEX_CMD=NONE +if which "flex" > /dev/null; then + LEX_CMD=`which flex` +elif which "lex" > /dev/null; then + LEX_CMD=`which lex` +else + echo "Error: You need lex (or flex) to generate the instrument script parser !" + exit -1 +fi -echo -n "Searching for a parser generator..." YACC_CMD=NONE if which "bison" > /dev/null; then YACC_CMD="`which bison` -y" elif which "yacc" > /dev/null; then YACC_CMD=`which yacc` else - 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 !" exit -1 fi -echo "OK ($YACC_CMD)" -echo "Generating LSCP parser..." +echo "OK ($LEX_CMD, $YACC_CMD)" + +echo -n "Generating instrument script parser ... " ( - cd $NETWORK_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" + cd $PARSER_SRC_DIR -echo -n "Updating Documentation/lscp.xml..." -(cd $SCRIPTS_DIR && ./update_grammar.pl) -echo "Done" + $LEX_CMD scanner.l + #mv -f lex.yy.c scanner.cpp + mv -f lex.InstrScript_.c scanner.cpp -echo -n "Generating src/network/lscp_shell_reference.cpp..." -(cd $SCRIPTS_DIR && ./generate_lscp_shell_reference.pl) + $YACC_CMD -d parser.y + $YACC_CMD parser.y + mv -f y.tab.h parser.h + mv -f y.tab.c parser.cpp +) echo "Done"