cmExprLexer.in.l 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 like this:
  7. flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
  8. Modify cmExprLexer.cxx:
  9. - remove TABs
  10. - remove use of the 'register' storage class specifier
  11. - remove "yyscanner" argument from these methods:
  12. yy_fatal_error, cmExpr_yyalloc, cmExpr_yyrealloc, cmExpr_yyfree
  13. - remove all YY_BREAK lines occurring right after return statements
  14. - change while ( 1 ) to for(;;)
  15. Modify cmExprLexer.h:
  16. - remove TABs
  17. - remove the yy_init_globals function
  18. - remove the block that includes unistd.h
  19. - remove #line directives (avoids bogus warning on old Sun)
  20. */
  21. #include "cmStandardLexer.h"
  22. #include "cmExprParserHelper.h"
  23. /* Replace the lexer input function. */
  24. #undef YY_INPUT
  25. #define YY_INPUT(buf, result, max_size) \
  26. { result = yyextra->LexInput(buf, max_size); }
  27. /* Include the set of tokens from the parser. */
  28. #include "cmExprParserTokens.h"
  29. /*--------------------------------------------------------------------------*/
  30. %}
  31. %option reentrant
  32. %option noyywrap
  33. %pointer
  34. %%
  35. [0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
  36. "+" { return exp_PLUS; }
  37. "-" { return exp_MINUS; }
  38. "*" { return exp_TIMES; }
  39. "/" { return exp_DIVIDE; }
  40. "%" { return exp_MOD; }
  41. "\|" { return exp_OR; }
  42. "&" { return exp_AND; }
  43. "^" { return exp_XOR; }
  44. "~" { return exp_NOT; }
  45. "<<" { return exp_SHIFTLEFT; }
  46. ">>" { return exp_SHIFTRIGHT; }
  47. "(" { return exp_OPENPARENT; }
  48. ")" { return exp_CLOSEPARENT; }
  49. %%