cmExprLexer.in.l 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. %{
  2. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  3. file Copyright.txt or https://cmake.org/licensing for details. */
  4. /*
  5. This file must be translated to C++ and modified to build everywhere.
  6. Run flex >= 2.6 like this:
  7. flex --nounistd -DFLEXINT_H --noline --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
  8. Modify cmExprLexer.cxx:
  9. - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
  10. - remove blank lines at end of file: sed -i '${/^$/d;}' cmExprLexer.h cmExprLexer.cxx
  11. - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmExprLexer.cxx
  12. */
  13. /* IWYU pragma: no_forward_declare yyguts_t */
  14. #ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
  15. #include "cmExprParserHelper.h"
  16. /* Replace the lexer input function. */
  17. #undef YY_INPUT
  18. #define YY_INPUT(buf, result, max_size) \
  19. do { result = yyextra->LexInput(buf, max_size); } while (0)
  20. /* Include the set of tokens from the parser. */
  21. #include "cmExprParserTokens.h"
  22. #include <string>
  23. /*--------------------------------------------------------------------------*/
  24. %}
  25. %option prefix="cmExpr_yy"
  26. %option reentrant
  27. %option noyywrap
  28. %pointer
  29. %%
  30. [ \t] {}
  31. [0-9][0-9]* { yylvalp->Number = std::stoll(yytext, nullptr, 10); return exp_NUMBER; }
  32. 0[xX][0-9a-fA-F][0-9a-fA-F]* { yylvalp->Number = std::stoll(yytext, nullptr, 16); return exp_NUMBER; }
  33. "+" { return exp_PLUS; }
  34. "-" { return exp_MINUS; }
  35. "*" { return exp_TIMES; }
  36. "/" { return exp_DIVIDE; }
  37. "%" { return exp_MOD; }
  38. "\|" { return exp_OR; }
  39. "&" { return exp_AND; }
  40. "^" { return exp_XOR; }
  41. "~" { return exp_NOT; }
  42. "<<" { return exp_SHIFTLEFT; }
  43. ">>" { return exp_SHIFTRIGHT; }
  44. "(" { return exp_OPENPARENT; }
  45. ")" { return exp_CLOSEPARENT; }
  46. . { yyextra->UnexpectedChar(yytext[0]); }
  47. %%
  48. /*--------------------------------------------------------------------------*/
  49. #endif /* __clang_analyzer__ */