regenerate-lexers.bash 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. set -e
  3. pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
  4. for lexer in \
  5. CommandArgument \
  6. DependsJava \
  7. Expr \
  8. Fortran
  9. do
  10. echo "Generating Lexer ${lexer}"
  11. flex --nounistd -DFLEXINT_H --noline --header-file=cm${lexer}Lexer.h -ocm${lexer}Lexer.cxx cm${lexer}Lexer.in.l
  12. sed -i 's/\s*$//' cm${lexer}Lexer.h cm${lexer}Lexer.cxx # remove trailing whitespaces
  13. sed -i '${/^$/d;}' cm${lexer}Lexer.h cm${lexer}Lexer.cxx # remove blank line at the end
  14. sed -i '1i#include "cmStandardLexer.h"' cm${lexer}Lexer.cxx # add cmStandardLexer.h include
  15. done
  16. # these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
  17. for lexer in ListFile
  18. do
  19. echo "Generating Lexer ${lexer}"
  20. flex --nounistd -DFLEXINT_H --noline -ocm${lexer}Lexer.c cm${lexer}Lexer.in.l
  21. sed -i 's/\s*$//' cm${lexer}Lexer.c # remove trailing whitespaces
  22. sed -i '${/^$/d;}' cm${lexer}Lexer.c # remove blank line at the end
  23. sed -i '1i#include "cmStandardLexer.h"' cm${lexer}Lexer.c # add cmStandardLexer.h include
  24. done
  25. popd > /dev/null