3e2792199e4c4ac32de7d6b956a93842d2654a5a
[alexxy/gromacs.git] / src / gromacs / selection / regenerate_parser.sh
1 #!/bin/bash
2 #
3 # This script runs Bison and/or Flex to regenerate the files as follows:
4 #   parser.y  -> parser.cpp, parser.h
5 #   scanner.l -> scanner.cpp, scanner_flex.h
6 # The commands are run only if the generated files are older than the
7 # Bison/Flex input files, or if a '-f' flag is provided.
8
9 FORCE=
10 if [ "x$1" == "x-f" ] ; then
11     FORCE=1
12 fi
13
14 if [ "x$BISON" == "x" ] ; then
15     BISON=bison
16 fi
17 if [ "x$FLEX" == "x" ] ; then
18     FLEX=flex
19 fi
20
21 # For convenience, change to the directory where the files are located
22 # if the script is run from the root of the source tree.
23 dirname=src/gromacs/selection
24 if [[ -f $dirname/parser.y && -f $dirname/scanner.l ]] ; then
25     cd $dirname
26 fi
27
28 [[ $FORCE || parser.y  -nt parser.cpp ]]  && $BISON -t -o parser.cpp --defines=parser.h parser.y
29 [[ $FORCE || scanner.l -nt scanner.cpp ]] && $FLEX -o scanner.cpp scanner.l