cmCommandArgumentParser.y 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 bison like this:
  17. bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
  18. Modify cmCommandArgumentParser.cxx:
  19. - remove TABs
  20. - add __HP_aCC to the #if test for yyerrorlab warning suppression
  21. */
  22. /* Configure the parser to use a lexer object. */
  23. #define YYPARSE_PARAM yyscanner
  24. #define YYLEX_PARAM yyscanner
  25. #define YYERROR_VERBOSE 1
  26. #define cmCommandArgument_yyerror(x) \
  27. cmCommandArgumentError(yyscanner, x)
  28. #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
  29. /*-------------------------------------------------------------------------*/
  30. #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */
  31. #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */
  32. #include "cmCommandArgumentParserTokens.h" /* Need YYSTYPE for YY_DECL. */
  33. /* Forward declare the lexer entry point. */
  34. YY_DECL;
  35. /* Internal utility functions. */
  36. static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
  37. #define YYDEBUG 1
  38. //#define YYMAXDEPTH 100000
  39. //#define YYINITDEPTH 10000
  40. /* Disable some warnings in the generated code. */
  41. #ifdef __BORLANDC__
  42. # pragma warn -8004 /* Variable assigned a value that is not used. */
  43. #endif
  44. #ifdef _MSC_VER
  45. # pragma warning (disable: 4102) /* Unused goto label. */
  46. # pragma warning (disable: 4065) /* Switch statement contains default but no case. */
  47. #endif
  48. %}
  49. /* Generate a reentrant parser object. */
  50. %pure_parser
  51. /*
  52. %union {
  53. char* string;
  54. }
  55. */
  56. /*-------------------------------------------------------------------------*/
  57. /* Tokens */
  58. %token cal_NCURLY
  59. %token cal_DCURLY
  60. %token cal_DOLLAR "$"
  61. %token cal_LCURLY "{"
  62. %token cal_RCURLY "}"
  63. %token cal_NAME
  64. %token cal_BSLASH "\\"
  65. %token cal_SYMBOL
  66. %token cal_AT "@"
  67. %token cal_ERROR
  68. %token cal_ATNAME
  69. /*-------------------------------------------------------------------------*/
  70. /* grammar */
  71. %%
  72. Start:
  73. GoalWithOptionalBackSlash
  74. {
  75. $<str>$ = 0;
  76. yyGetParser->SetResult($<str>1);
  77. }
  78. GoalWithOptionalBackSlash:
  79. Goal
  80. {
  81. $<str>$ = $<str>1;
  82. }
  83. |
  84. Goal cal_BSLASH
  85. {
  86. $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
  87. }
  88. Goal:
  89. {
  90. $<str>$ = 0;
  91. }
  92. |
  93. String Goal
  94. {
  95. $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
  96. }
  97. String:
  98. OuterText
  99. {
  100. $<str>$ = $<str>1;
  101. }
  102. |
  103. Variable
  104. {
  105. $<str>$ = $<str>1;
  106. }
  107. OuterText:
  108. cal_NAME
  109. {
  110. $<str>$ = $<str>1;
  111. }
  112. |
  113. cal_AT
  114. {
  115. $<str>$ = $<str>1;
  116. }
  117. |
  118. cal_DOLLAR
  119. {
  120. $<str>$ = $<str>1;
  121. }
  122. |
  123. cal_LCURLY
  124. {
  125. $<str>$ = $<str>1;
  126. }
  127. |
  128. cal_RCURLY
  129. {
  130. $<str>$ = $<str>1;
  131. }
  132. |
  133. cal_SYMBOL
  134. {
  135. $<str>$ = $<str>1;
  136. }
  137. Variable:
  138. cal_NCURLY MultipleIds cal_RCURLY
  139. {
  140. $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
  141. //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
  142. }
  143. |
  144. cal_DCURLY MultipleIds cal_RCURLY
  145. {
  146. $<str>$ = yyGetParser->ExpandVariable($<str>2);
  147. //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
  148. }
  149. |
  150. cal_ATNAME
  151. {
  152. $<str>$ = yyGetParser->ExpandVariable($<str>1);
  153. }
  154. MultipleIds:
  155. {
  156. $<str>$ = 0;
  157. }
  158. |
  159. ID MultipleIds
  160. {
  161. $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
  162. }
  163. ID:
  164. cal_NAME
  165. {
  166. $<str>$ = $<str>1;
  167. }
  168. |
  169. Variable
  170. {
  171. $<str>$ = $<str>1;
  172. }
  173. %%
  174. /* End of grammar */
  175. /*--------------------------------------------------------------------------*/
  176. void cmCommandArgumentError(yyscan_t yyscanner, const char* message)
  177. {
  178. yyGetParser->Error(message);
  179. }