ENH: add submit via cp mode
[cmake.git] / Source / cmCommandArgumentParser.y
blob8dfd41c66380be7083feceebc5c33447fac8b606
1 %{
2 /*=========================================================================
4 Program: CMake - Cross-Platform Makefile Generator
5 Module: $RCSfile: cmCommandArgumentParser.y,v $
6 Language: C++
7 Date: $Date: 2008-12-18 14:58:01 $
8 Version: $Revision: 1.12 $
10 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
11 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 This file must be translated to C and modified to build everywhere.
22 Run bison like this:
24 bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
26 Modify cmCommandArgumentParser.cxx:
27 - remove TABs
28 - put header block at top of file
32 #include "cmStandardIncludes.h"
34 /* Configure the parser to use a lexer object. */
35 #define YYPARSE_PARAM yyscanner
36 #define YYLEX_PARAM yyscanner
37 #define YYERROR_VERBOSE 1
38 #define cmCommandArgument_yyerror(x) \
39 cmCommandArgumentError(yyscanner, x)
40 #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
42 /* Make sure malloc and free are available on QNX. */
43 #ifdef __QNX__
44 # include <malloc.h>
45 #endif
47 /* Make sure the parser uses standard memory allocation. The default
48 generated parser malloc/free declarations do not work on all
49 platforms. */
50 #include <stdlib.h>
51 #define YYMALLOC malloc
52 #define YYFREE free
54 /*-------------------------------------------------------------------------*/
55 #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */
56 #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */
57 #include "cmCommandArgumentParserTokens.h" /* Need YYSTYPE for YY_DECL. */
59 /* Forward declare the lexer entry point. */
60 YY_DECL;
62 /* Internal utility functions. */
63 static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
65 #define YYDEBUG 1
66 /* Configure the parser to support large input. */
67 #define YYMAXDEPTH 100000
68 #define YYINITDEPTH 10000
70 /* Disable some warnings in the generated code. */
71 #ifdef __BORLANDC__
72 # pragma warn -8004 /* Variable assigned a value that is not used. */
73 # pragma warn -8008 /* condition always returns true */
74 # pragma warn -8060 /* possibly incorrect assignment */
75 # pragma warn -8066 /* unreachable code */
76 #endif
77 #ifdef _MSC_VER
78 # pragma warning (disable: 4102) /* Unused goto label. */
79 # pragma warning (disable: 4065) /* Switch statement contains default but no
80 case. */
81 # pragma warning (disable: 4244) /* loss of precision */
82 # pragma warning (disable: 4702) /* unreachable code */
83 #endif
86 /* Generate a reentrant parser object. */
87 %pure_parser
90 %union {
91 char* string;
95 /*-------------------------------------------------------------------------*/
96 /* Tokens */
97 %token cal_ENVCURLY
98 %token cal_NCURLY
99 %token cal_DCURLY
100 %token cal_DOLLAR "$"
101 %token cal_LCURLY "{"
102 %token cal_RCURLY "}"
103 %token cal_NAME
104 %token cal_BSLASH "\\"
105 %token cal_SYMBOL
106 %token cal_AT "@"
107 %token cal_ERROR
108 %token cal_ATNAME
110 /*-------------------------------------------------------------------------*/
111 /* grammar */
115 Start:
116 GoalWithOptionalBackSlash
118 $<str>$ = 0;
119 yyGetParser->SetResult($<str>1);
122 GoalWithOptionalBackSlash:
123 Goal
125 $<str>$ = $<str>1;
128 Goal cal_BSLASH
130 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
133 Goal:
135 $<str>$ = 0;
138 String Goal
140 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
143 String:
144 OuterText
146 $<str>$ = $<str>1;
149 Variable
151 $<str>$ = $<str>1;
154 OuterText:
155 cal_NAME
157 $<str>$ = $<str>1;
160 cal_AT
162 $<str>$ = $<str>1;
165 cal_DOLLAR
167 $<str>$ = $<str>1;
170 cal_LCURLY
172 $<str>$ = $<str>1;
175 cal_RCURLY
177 $<str>$ = $<str>1;
180 cal_SYMBOL
182 $<str>$ = $<str>1;
185 Variable:
186 cal_ENVCURLY EnvVarName cal_RCURLY
188 $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
189 //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
192 cal_NCURLY MultipleIds cal_RCURLY
194 $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
195 //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
198 cal_DCURLY MultipleIds cal_RCURLY
200 $<str>$ = yyGetParser->ExpandVariable($<str>2);
201 //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
204 cal_ATNAME
206 $<str>$ = yyGetParser->ExpandVariableForAt($<str>1);
209 EnvVarName:
210 MultipleIds
212 $<str>$ = $<str>1;
215 cal_SYMBOL EnvVarName
217 $<str>$ = $<str>1;
220 MultipleIds:
222 $<str>$ = 0;
225 ID MultipleIds
227 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
231 cal_NAME
233 $<str>$ = $<str>1;
236 Variable
238 $<str>$ = $<str>1;
243 /* End of grammar */
245 /*--------------------------------------------------------------------------*/
246 void cmCommandArgumentError(yyscan_t yyscanner, const char* message)
248 yyGetParser->Error(message);