cmExprLexer.in.l 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include "cmExprParserHelper.h"
  15. /* Replace the lexer input function. */
  16. #undef YY_INPUT
  17. #define YY_INPUT(buf, result, max_size) \
  18. { result = yyextra->LexInput(buf, max_size); }
  19. /* Include the set of tokens from the parser. */
  20. #include "cmExprParserTokens.h"
  21. #include <string>
  22. /*--------------------------------------------------------------------------*/
  23. %}
  24. %option prefix="cmExpr_yy"
  25. %option reentrant
  26. %option noyywrap
  27. %pointer
  28. %%
  29. [ \t] {}
  30. [0-9][0-9]* { yylvalp->Number = std::stoll(yytext, nullptr, 10); return exp_NUMBER; }
  31. 0[xX][0-9a-fA-F][0-9a-fA-F]* { yylvalp->Number = std::stoll(yytext, nullptr, 16); return exp_NUMBER; }
  32. "+" { return exp_PLUS; }
  33. "-" { return exp_MINUS; }
  34. "*" { return exp_TIMES; }
  35. "/" { return exp_DIVIDE; }
  36. "%" { return exp_MOD; }
  37. "\|" { return exp_OR; }
  38. "&" { return exp_AND; }
  39. "^" { return exp_XOR; }
  40. "~" { return exp_NOT; }
  41. "<<" { return exp_SHIFTLEFT; }
  42. ">>" { return exp_SHIFTRIGHT; }
  43. "(" { return exp_OPENPARENT; }
  44. ")" { return exp_CLOSEPARENT; }
  45. . {return exp_UNEXPECTED;}
  46. %%