Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/Scripts/regenerate-lexers.bash
5015 views
1
#!/usr/bin/env bash
2
3
set -e
4
5
forced=1
6
if [[ "${1}" = "make" ]]; then
7
forced=0
8
fi
9
10
pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
11
12
extra_args_CommandArgument="--never-interactive --batch"
13
14
for lexer in \
15
CTestResourceGroups \
16
DependsJava \
17
Expr \
18
Fortran \
19
GccDepfile
20
do
21
cxx_file=cm${lexer}Lexer.cxx
22
h_file=cm${lexer}Lexer.h
23
in_file=cm${lexer}Lexer.in.l
24
25
if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
26
extra_args=`eval echo \\${extra_args_\${lexer}}`
27
echo "Generating Lexer ${lexer}"
28
flex --nounistd ${extra_args} -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}
29
sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces
30
sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end
31
sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include
32
else
33
echo "Skipped generating Lexer ${lexer}"
34
fi
35
done
36
37
38
# these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
39
for lexer in ListFile
40
do
41
c_file=cm${lexer}Lexer.c
42
in_file=cm${lexer}Lexer.in.l
43
44
if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then
45
echo "Generating Lexer ${lexer}"
46
flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}
47
sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces
48
sed -i '${/^$/d;}' ${c_file} # remove blank line at the end
49
sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include
50
else
51
echo "Skipped generating Lexer ${lexer}"
52
fi
53
54
done
55
56
popd > /dev/null
57
58