STYLE: Fix line-too-long
[cmake.git] / Source / cmCommandArgumentParser.y
blob8fa53299ca64f694015c10c4dc7bf7694ceff25c
1 %{
2 /*=========================================================================
4 Program: CMake - Cross-Platform Makefile Generator
5 Module: $RCSfile: cmCommandArgumentParser.y,v $
6 Language: C++
7 Date: $Date: 2006-10-04 18:37:41 $
8 Version: $Revision: 1.10 $
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
31 #include "cmStandardIncludes.h"
33 /* Configure the parser to use a lexer object. */
34 #define YYPARSE_PARAM yyscanner
35 #define YYLEX_PARAM yyscanner
36 #define YYERROR_VERBOSE 1
37 #define cmCommandArgument_yyerror(x) \
38 cmCommandArgumentError(yyscanner, x)
39 #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
41 /* Make sure malloc and free are available on QNX. */
42 #ifdef __QNX__
43 # include <malloc.h>
44 #endif
46 /* Make sure the parser uses standard memory allocation. The default
47 generated parser malloc/free declarations do not work on all
48 platforms. */
49 #include <stdlib.h>
50 #define YYMALLOC malloc
51 #define YYFREE free
53 /*-------------------------------------------------------------------------*/
54 #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */
55 #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */
56 #include "cmCommandArgumentParserTokens.h" /* Need YYSTYPE for YY_DECL. */
58 /* Forward declare the lexer entry point. */
59 YY_DECL;
61 /* Internal utility functions. */
62 static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
64 #define YYDEBUG 1
65 //#define YYMAXDEPTH 100000
66 //#define YYINITDEPTH 10000
69 /* Disable some warnings in the generated code. */
70 #ifdef __BORLANDC__
71 # pragma warn -8004 /* Variable assigned a value that is not used. */
72 # pragma warn -8008 /* condition always returns true */
73 # pragma warn -8060 /* possibly incorrect assignment */
74 # pragma warn -8066 /* unreachable code */
75 #endif
76 #ifdef _MSC_VER
77 # pragma warning (disable: 4102) /* Unused goto label. */
78 # pragma warning (disable: 4065) /* Switch statement contains default but no
79 case. */
80 #endif
83 /* Generate a reentrant parser object. */
84 %pure_parser
87 %union {
88 char* string;
92 /*-------------------------------------------------------------------------*/
93 /* Tokens */
94 %token cal_NCURLY
95 %token cal_DCURLY
96 %token cal_DOLLAR "$"
97 %token cal_LCURLY "{"
98 %token cal_RCURLY "}"
99 %token cal_NAME
100 %token cal_BSLASH "\\"
101 %token cal_SYMBOL
102 %token cal_AT "@"
103 %token cal_ERROR
104 %token cal_ATNAME
106 /*-------------------------------------------------------------------------*/
107 /* grammar */
111 Start:
112 GoalWithOptionalBackSlash
114 $<str>$ = 0;
115 yyGetParser->SetResult($<str>1);
118 GoalWithOptionalBackSlash:
119 Goal
121 $<str>$ = $<str>1;
124 Goal cal_BSLASH
126 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
129 Goal:
131 $<str>$ = 0;
134 String Goal
136 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
139 String:
140 OuterText
142 $<str>$ = $<str>1;
145 Variable
147 $<str>$ = $<str>1;
150 OuterText:
151 cal_NAME
153 $<str>$ = $<str>1;
156 cal_AT
158 $<str>$ = $<str>1;
161 cal_DOLLAR
163 $<str>$ = $<str>1;
166 cal_LCURLY
168 $<str>$ = $<str>1;
171 cal_RCURLY
173 $<str>$ = $<str>1;
176 cal_SYMBOL
178 $<str>$ = $<str>1;
181 Variable:
182 cal_NCURLY MultipleIds cal_RCURLY
184 $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
185 //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
188 cal_DCURLY MultipleIds cal_RCURLY
190 $<str>$ = yyGetParser->ExpandVariable($<str>2);
191 //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
194 cal_ATNAME
196 $<str>$ = yyGetParser->ExpandVariableForAt($<str>1);
199 MultipleIds:
201 $<str>$ = 0;
204 ID MultipleIds
206 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
210 cal_NAME
212 $<str>$ = $<str>1;
215 Variable
217 $<str>$ = $<str>1;
222 /* End of grammar */
224 /*--------------------------------------------------------------------------*/
225 void cmCommandArgumentError(yyscan_t yyscanner, const char* message)
227 yyGetParser->Error(message);