cmExprLexer.in.l 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. %{
  2. /*=========================================================================
  3. Program: CMake - Cross-Platform Makefile Generator
  4. Module: $RCSfile$
  5. Language: C++
  6. Date: $Date$
  7. Version: $Revision$
  8. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  9. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  10. This software is distributed WITHOUT ANY WARRANTY; without even
  11. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. PURPOSE. See the above copyright notices for more information.
  13. =========================================================================*/
  14. /*
  15. This file must be translated to C and modified to build everywhere.
  16. Run flex like this:
  17. flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
  18. Modify cmExprLexer.cxx:
  19. - remove TABs
  20. - remove "yyscanner" argument from these methods:
  21. yy_fatal_error, yyalloc, yyrealloc, yyfree
  22. - remove all YY_BREAK lines occurring right after return statements
  23. - change while ( 1 ) to for(;;)
  24. Modify cmExprLexer.h:
  25. - remove TABs
  26. - remove the yy_init_globals function
  27. - remove the block that includes unistd.h
  28. - remove #line directives (avoids bogus warning on old Sun)
  29. */
  30. #include "cmExprParserHelper.h"
  31. /* Disable some warnings. */
  32. #if defined(_MSC_VER)
  33. # pragma warning ( disable : 4127 )
  34. # pragma warning ( disable : 4131 )
  35. # pragma warning ( disable : 4244 )
  36. # pragma warning ( disable : 4251 )
  37. # pragma warning ( disable : 4267 )
  38. # pragma warning ( disable : 4305 )
  39. # pragma warning ( disable : 4309 )
  40. # pragma warning ( disable : 4706 )
  41. # pragma warning ( disable : 4786 )
  42. #endif
  43. /* Disable features we do not need. */
  44. #define YY_NEVER_INTERACTIVE 1
  45. #undef ECHO /* SGI termios defines this differently. */
  46. #define ECHO
  47. /* Replace the lexer input function. */
  48. #undef YY_INPUT
  49. #define YY_INPUT(buf, result, max_size) \
  50. { result = yyextra->LexInput(buf, max_size); }
  51. /* Include the set of tokens from the parser. */
  52. #include "cmExprParserTokens.h"
  53. #if defined( _WIN32 ) && !defined( __CYGWIN__ )
  54. /* Handle Windows properly */
  55. # include <io.h>
  56. # if defined( _MSC_VER )
  57. # define isatty _isatty
  58. # endif
  59. # define YY_NO_UNISTD_H 1
  60. #endif
  61. /*--------------------------------------------------------------------------*/
  62. %}
  63. %option reentrant
  64. %option noyywrap
  65. %pointer
  66. %%
  67. [0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
  68. "+" { return exp_PLUS; }
  69. "-" { return exp_MINUS; }
  70. "*" { return exp_TIMES; }
  71. "/" { return exp_DIVIDE; }
  72. "%" { return exp_MOD; }
  73. "\|" { return exp_OR; }
  74. "&" { return exp_AND; }
  75. "^" { return exp_XOR; }
  76. "~" { return exp_NOT; }
  77. "<<" { return exp_SHIFTLEFT; }
  78. ">>" { return exp_SHIFTRIGHT; }
  79. "(" { return exp_OPENPARENT; }
  80. ")" { return exp_CLOSEPARENT; }
  81. %%