cmExprLexer.in.l 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. "+" { return exp_PLUS; }
  32. "-" { return exp_MINUS; }
  33. "*" { return exp_TIMES; }
  34. "/" { return exp_DIVIDE; }
  35. "%" { return exp_MOD; }
  36. "\|" { return exp_OR; }
  37. "&" { return exp_AND; }
  38. "^" { return exp_XOR; }
  39. "~" { return exp_NOT; }
  40. "<<" { return exp_SHIFTLEFT; }
  41. ">>" { return exp_SHIFTRIGHT; }
  42. "(" { return exp_OPENPARENT; }
  43. ")" { return exp_CLOSEPARENT; }
  44. . {return exp_UNEXPECTED;}
  45. %%