regenerate-lexers.bash 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. set -e
  3. forced=1
  4. if [[ "${1}" = "make" ]]; then
  5. forced=0
  6. fi
  7. pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
  8. extra_args_CommandArgument="--never-interactive --batch"
  9. for lexer in \
  10. CommandArgument \
  11. CTestResourceGroups \
  12. DependsJava \
  13. Expr \
  14. Fortran \
  15. GccDepfile
  16. do
  17. cxx_file=cm${lexer}Lexer.cxx
  18. h_file=cm${lexer}Lexer.h
  19. in_file=cm${lexer}Lexer.in.l
  20. if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
  21. extra_args=`eval echo \\${extra_args_\${lexer}}`
  22. echo "Generating Lexer ${lexer}"
  23. flex --nounistd ${extra_args} -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}
  24. sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces
  25. sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end
  26. sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include
  27. else
  28. echo "Skipped generating Lexer ${lexer}"
  29. fi
  30. done
  31. # these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
  32. for lexer in ListFile
  33. do
  34. c_file=cm${lexer}Lexer.c
  35. in_file=cm${lexer}Lexer.in.l
  36. if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then
  37. echo "Generating Lexer ${lexer}"
  38. flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}
  39. sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces
  40. sed -i '${/^$/d;}' ${c_file} # remove blank line at the end
  41. sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include
  42. else
  43. echo "Skipped generating Lexer ${lexer}"
  44. fi
  45. done
  46. popd > /dev/null