cmExprLexer.in.l 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. %{
  2. /*============================================================================
  3. CMake - Cross Platform Makefile Generator
  4. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  5. Distributed under the OSI-approved BSD License (the "License");
  6. see accompanying file Copyright.txt for details.
  7. This software is distributed WITHOUT ANY WARRANTY; without even the
  8. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. See the License for more information.
  10. ============================================================================*/
  11. /*
  12. This file must be translated to C and modified to build everywhere.
  13. Run flex like this:
  14. flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
  15. Modify cmExprLexer.cxx:
  16. - remove TABs
  17. - remove "yyscanner" argument from these methods:
  18. yy_fatal_error, cmExpr_yyalloc, cmExpr_yyrealloc, cmExpr_yyfree
  19. - remove all YY_BREAK lines occurring right after return statements
  20. - change while ( 1 ) to for(;;)
  21. Modify cmExprLexer.h:
  22. - remove TABs
  23. - remove the yy_init_globals function
  24. - remove the block that includes unistd.h
  25. - remove #line directives (avoids bogus warning on old Sun)
  26. */
  27. #include "cmStandardLexer.h"
  28. #include "cmExprParserHelper.h"
  29. /* Replace the lexer input function. */
  30. #undef YY_INPUT
  31. #define YY_INPUT(buf, result, max_size) \
  32. { result = yyextra->LexInput(buf, max_size); }
  33. /* Include the set of tokens from the parser. */
  34. #include "cmExprParserTokens.h"
  35. /*--------------------------------------------------------------------------*/
  36. %}
  37. %option reentrant
  38. %option noyywrap
  39. %pointer
  40. %%
  41. [0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
  42. "+" { return exp_PLUS; }
  43. "-" { return exp_MINUS; }
  44. "*" { return exp_TIMES; }
  45. "/" { return exp_DIVIDE; }
  46. "%" { return exp_MOD; }
  47. "\|" { return exp_OR; }
  48. "&" { return exp_AND; }
  49. "^" { return exp_XOR; }
  50. "~" { return exp_NOT; }
  51. "<<" { return exp_SHIFTLEFT; }
  52. ">>" { return exp_SHIFTRIGHT; }
  53. "(" { return exp_OPENPARENT; }
  54. ")" { return exp_CLOSEPARENT; }
  55. %%