diff options
author | Matthias Maennich <matthias@maennich.net> | 2017-08-29 12:58:34 (GMT) |
---|---|---|
committer | Matthias Maennich <matthias@maennich.net> | 2017-08-29 12:58:34 (GMT) |
commit | 168b97a5c52560b3fe892bafeb1cc719ce3d0514 (patch) | |
tree | 4c4720e3d937263f92ec3f052eed8501679fa537 /Utilities | |
parent | 376c13958d84bd23f3a9f32aab9692df1f2d47fe (diff) | |
download | CMake-168b97a5c52560b3fe892bafeb1cc719ce3d0514.zip CMake-168b97a5c52560b3fe892bafeb1cc719ce3d0514.tar.gz CMake-168b97a5c52560b3fe892bafeb1cc719ce3d0514.tar.bz2 |
Lexer: add a helper script to automate generating the lexers
note: this depends on
- a suitable flex version in PATH (currently 2.6.4)
- a suitable version of 'sed' in PATH (e.g. GNU sed)
Signed-off-by: Matthias Maennich <matthias@maennich.net>
Diffstat (limited to 'Utilities')
-rwxr-xr-x | Utilities/Scripts/regenerate-lexers.bash | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Utilities/Scripts/regenerate-lexers.bash b/Utilities/Scripts/regenerate-lexers.bash new file mode 100755 index 0000000..22b681f --- /dev/null +++ b/Utilities/Scripts/regenerate-lexers.bash @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -e + +pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null + +for lexer in \ + CommandArgument \ + DependsJava \ + Expr \ + Fortran +do + echo "Generating Lexer ${lexer}" + flex --nounistd -DFLEXINT_H --noline --header-file=cm${lexer}Lexer.h -ocm${lexer}Lexer.cxx cm${lexer}Lexer.in.l + sed -i 's/\s*$//' cm${lexer}Lexer.h cm${lexer}Lexer.cxx # remove trailing whitespaces + sed -i '${/^$/d;}' cm${lexer}Lexer.h cm${lexer}Lexer.cxx # remove blank line at the end + sed -i '1i#include "cmStandardLexer.h"' cm${lexer}Lexer.cxx # add cmStandardLexer.h include +done + + +# these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header +for lexer in ListFile +do + + echo "Generating Lexer ${lexer}" + flex --nounistd -DFLEXINT_H --noline -ocm${lexer}Lexer.c cm${lexer}Lexer.in.l + sed -i 's/\s*$//' cm${lexer}Lexer.c # remove trailing whitespaces + sed -i '${/^$/d;}' cm${lexer}Lexer.c # remove blank line at the end + sed -i '1i#include "cmStandardLexer.h"' cm${lexer}Lexer.c # add cmStandardLexer.h include + +done + +popd > /dev/null |