regenerate-lexers.bash 1.7 KB

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