cmCommandArgumentLexer.in.l 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
  18. Modify cmCommandArgumentLexer.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 cmCommandArgumentLexer.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 "cmCommandArgumentParserHelper.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 "cmCommandArgumentParserTokens.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. \$[A-Za-z0-9/_.-]+\{ {
  68. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  69. yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
  70. return cal_NCURLY;
  71. }
  72. @[A-Za-z0-9/_.-]+@ {
  73. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  74. yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
  75. return cal_ATNAME;
  76. }
  77. "${" {
  78. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  79. //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  80. yylvalp->str = yyextra->m_DCURLYVariable;
  81. return cal_DCURLY;
  82. }
  83. "}" {
  84. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  85. //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  86. yylvalp->str = yyextra->m_RCURLYVariable;
  87. return cal_RCURLY;
  88. }
  89. "@" {
  90. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  91. //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  92. yylvalp->str = yyextra->m_ATVariable;
  93. return cal_AT;
  94. }
  95. [A-Za-z0-9/_.-]+ {
  96. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  97. yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  98. return cal_NAME;
  99. }
  100. \\. {
  101. if ( !yyextra->HandleEscapeSymbol(yylvalp, *(yytext+1)) )
  102. {
  103. return cal_ERROR;
  104. }
  105. return cal_SYMBOL;
  106. }
  107. [^\${}\\@]+ {
  108. //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
  109. yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  110. return cal_SYMBOL;
  111. }
  112. "$" {
  113. //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  114. yylvalp->str = yyextra->m_DOLLARVariable;
  115. return cal_DOLLAR;
  116. }
  117. "{" {
  118. //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  119. yylvalp->str = yyextra->m_LCURLYVariable;
  120. return cal_LCURLY;
  121. }
  122. "\\" {
  123. //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
  124. yylvalp->str = yyextra->m_BSLASHVariable;
  125. return cal_BSLASH;
  126. }
  127. %%