regenerate-lexers.bash 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. for lexer in \
  9. CommandArgument \
  10. CTestProcesses \
  11. DependsJava \
  12. Expr \
  13. Fortran
  14. do
  15. cxx_file=cm${lexer}Lexer.cxx
  16. h_file=cm${lexer}Lexer.h
  17. in_file=cm${lexer}Lexer.in.l
  18. if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
  19. echo "Generating Lexer ${lexer}"
  20. flex --nounistd -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}
  21. sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces
  22. sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end
  23. sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include
  24. else
  25. echo "Skipped generating Lexer ${lexer}"
  26. fi
  27. done
  28. # these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
  29. for lexer in ListFile
  30. do
  31. c_file=cm${lexer}Lexer.c
  32. in_file=cm${lexer}Lexer.in.l
  33. if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then
  34. echo "Generating Lexer ${lexer}"
  35. flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}
  36. sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces
  37. sed -i '${/^$/d;}' ${c_file} # remove blank line at the end
  38. sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include
  39. else
  40. echo "Skipped generating Lexer ${lexer}"
  41. fi
  42. done
  43. popd > /dev/null