mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
flex 2.6.3 introduces symbol remapping through macro definitions. hence the
change appears bigger than one would expect from a minor version upgrade.
In addition some manual cleanup that had to be done previously is now
obsolete. namely:
- the size_t cast of _yybytes_len in yy_scan_bytes
(i is now also defined int and not size_t anymore)
- the redefinition of yyl within yy_find_action
(yyl is now already defined as int)
Line number preprocessor directives (#line) were previously generated into
the c source file. This actually breaks debugging as debuggers have a hard
time finding the original cmExprLexer.in.l and mapping the current
instruction to a meaningful location within that file.
The prefix "cmExpr_yy" can already be set as %option directly.
For convenience also provide a sed command for all the manual steps that
need to be done after generating.
Signed-off-by: Matthias Maennich <matthias@maennich.net>
59 lines
1.5 KiB
Plaintext
59 lines
1.5 KiB
Plaintext
%{
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
/*
|
|
|
|
This file must be translated to C++ and modified to build everywhere.
|
|
|
|
Run flex >= 2.6 like this:
|
|
|
|
flex --nounistd -DFLEXINT_H --noline --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
|
|
|
|
Modify cmExprLexer.cxx:
|
|
- remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
|
|
- remove blank lines at end of file: sed -i '${/^$/d;}' cmExprLexer.h cmExprLexer.cxx
|
|
- #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmExprLexer.cxx
|
|
|
|
*/
|
|
|
|
/* IWYU pragma: no_forward_declare yyguts_t */
|
|
|
|
#include "cmExprParserHelper.h"
|
|
|
|
/* Replace the lexer input function. */
|
|
#undef YY_INPUT
|
|
#define YY_INPUT(buf, result, max_size) \
|
|
{ result = yyextra->LexInput(buf, max_size); }
|
|
|
|
/* Include the set of tokens from the parser. */
|
|
#include "cmExprParserTokens.h"
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
%}
|
|
|
|
%option prefix="cmExpr_yy"
|
|
|
|
%option reentrant
|
|
%option noyywrap
|
|
%pointer
|
|
|
|
%%
|
|
|
|
[0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
|
|
|
|
"+" { return exp_PLUS; }
|
|
"-" { return exp_MINUS; }
|
|
"*" { return exp_TIMES; }
|
|
"/" { return exp_DIVIDE; }
|
|
"%" { return exp_MOD; }
|
|
"\|" { return exp_OR; }
|
|
"&" { return exp_AND; }
|
|
"^" { return exp_XOR; }
|
|
"~" { return exp_NOT; }
|
|
"<<" { return exp_SHIFTLEFT; }
|
|
">>" { return exp_SHIFTRIGHT; }
|
|
"(" { return exp_OPENPARENT; }
|
|
")" { return exp_CLOSEPARENT; }
|
|
|
|
%%
|