Path: blob/master/Utilities/Scripts/regenerate-lexers.bash
5015 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 \14CTestResourceGroups \15DependsJava \16Expr \17Fortran \18GccDepfile19do20cxx_file=cm${lexer}Lexer.cxx21h_file=cm${lexer}Lexer.h22in_file=cm${lexer}Lexer.in.l2324if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then25extra_args=`eval echo \\${extra_args_\${lexer}}`26echo "Generating Lexer ${lexer}"27flex --nounistd ${extra_args} -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}28sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces29sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end30sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include31else32echo "Skipped generating Lexer ${lexer}"33fi34done353637# these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header38for lexer in ListFile39do40c_file=cm${lexer}Lexer.c41in_file=cm${lexer}Lexer.in.l4243if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then44echo "Generating Lexer ${lexer}"45flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}46sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces47sed -i '${/^$/d;}' ${c_file} # remove blank line at the end48sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include49else50echo "Skipped generating Lexer ${lexer}"51fi5253done5455popd > /dev/null565758