Path: blob/master/Utilities/Scripts/regenerate-lexers.bash
3148 views
#!/usr/bin/env bash12set -e34forced=15if [[ "${1}" = "make" ]]; then6forced=07fi89pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null1011extra_args_CommandArgument="--never-interactive --batch"1213for lexer in \14CommandArgument \15CTestResourceGroups \16DependsJava \17Expr \18Fortran \19GccDepfile20do21cxx_file=cm${lexer}Lexer.cxx22h_file=cm${lexer}Lexer.h23in_file=cm${lexer}Lexer.in.l2425if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then26extra_args=`eval echo \\${extra_args_\${lexer}}`27echo "Generating Lexer ${lexer}"28flex --nounistd ${extra_args} -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}29sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces30sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end31sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include32else33echo "Skipped generating Lexer ${lexer}"34fi35done363738# these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header39for lexer in ListFile40do41c_file=cm${lexer}Lexer.c42in_file=cm${lexer}Lexer.in.l4344if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then45echo "Generating Lexer ${lexer}"46flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}47sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces48sed -i '${/^$/d;}' ${c_file} # remove blank line at the end49sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include50else51echo "Skipped generating Lexer ${lexer}"52fi5354done5556popd > /dev/null575859