CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / LexerParser / cmCommandArgumentParser.y
blob59f4b322b4db7cd646453f0cea79acf76cc8200a
1 %{
2 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
3 file Copyright.txt or https://cmake.org/licensing for details. */
4 /*
6 This file must be translated to C and modified to build everywhere.
8 Run bison like this:
10 bison --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
14 #include "cmConfigure.h" // IWYU pragma: keep
16 #include <string.h>
18 #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
20 /* Make sure malloc and free are available on QNX. */
21 #ifdef __QNX__
22 # include <malloc.h>
23 #endif
25 /* Make sure the parser uses standard memory allocation. The default
26 generated parser malloc/free declarations do not work on all
27 platforms. */
28 #include <stdlib.h>
29 #define YYMALLOC malloc
30 #define YYFREE free
32 /*-------------------------------------------------------------------------*/
33 #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */
34 #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */
36 /* Forward declare the lexer entry point. */
37 YY_DECL;
39 /* Helper function to forward error callback from parser. */
40 static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message);
42 /* Configure the parser to support large input. */
43 #define YYMAXDEPTH 100000
44 #define YYINITDEPTH 10000
46 /* Disable some warnings in the generated code. */
47 #ifdef _MSC_VER
48 # pragma warning (disable: 4102) /* Unused goto label. */
49 # pragma warning (disable: 4065) /* Switch statement contains default but no
50 case. */
51 # pragma warning (disable: 4244) /* loss of precision */
52 # pragma warning (disable: 4702) /* unreachable code */
53 #endif
54 #if defined(__GNUC__) && __GNUC__ >= 8
55 # pragma GCC diagnostic ignored "-Wconversion"
56 # pragma GCC diagnostic ignored "-Wfree-nonheap-object"
57 #endif
58 #if defined(__clang__) && defined(__has_warning)
59 # if __has_warning("-Wunused-but-set-variable")
60 # pragma clang diagnostic ignored "-Wunused-but-set-variable"
61 # endif
62 #endif
65 /* Generate a reentrant parser object. */
66 %define api.pure
68 /* Configure the parser to use a lexer object. */
69 %lex-param {yyscan_t yyscanner}
70 %parse-param {yyscan_t yyscanner}
72 %define parse.error verbose
75 %union {
76 char* string;
80 /*-------------------------------------------------------------------------*/
81 /* Tokens */
82 %token cal_ENVCURLY
83 %token cal_NCURLY
84 %token cal_DCURLY
85 %token cal_DOLLAR "$"
86 %token cal_LCURLY "{"
87 %token cal_RCURLY "}"
88 %token cal_NAME
89 %token cal_BSLASH "\\"
90 %token cal_SYMBOL
91 %token cal_AT "@"
92 %token cal_ERROR
93 %token cal_ATNAME
95 /*-------------------------------------------------------------------------*/
96 /* grammar */
100 Start:
101 GoalWithOptionalBackSlash {
102 $<str>$ = 0;
103 yyGetParser->SetResult($<str>1);
106 GoalWithOptionalBackSlash:
107 Goal {
108 $<str>$ = $<str>1;
110 | Goal cal_BSLASH {
111 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
114 Goal:
116 $<str>$ = 0;
118 | String Goal {
119 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
122 String:
123 OuterText {
124 $<str>$ = $<str>1;
126 | Variable {
127 $<str>$ = $<str>1;
130 OuterText:
131 cal_NAME {
132 $<str>$ = $<str>1;
134 | cal_AT {
135 $<str>$ = $<str>1;
137 | cal_DOLLAR {
138 $<str>$ = $<str>1;
140 | cal_LCURLY {
141 $<str>$ = $<str>1;
143 | cal_RCURLY {
144 $<str>$ = $<str>1;
146 | cal_SYMBOL {
147 $<str>$ = $<str>1;
150 Variable:
151 cal_ENVCURLY EnvVarName cal_RCURLY {
152 $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1, $<str>2);
154 | cal_NCURLY MultipleIds cal_RCURLY {
155 $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1, $<str>2);
157 | cal_DCURLY MultipleIds cal_RCURLY {
158 $<str>$ = yyGetParser->ExpandVariable($<str>2);
160 | cal_ATNAME {
161 $<str>$ = yyGetParser->ExpandVariableForAt($<str>1);
164 EnvVarName:
165 MultipleIds {
166 $<str>$ = $<str>1;
168 | cal_SYMBOL EnvVarName {
169 $<str>$ = $<str>1;
172 MultipleIds:
174 $<str>$ = 0;
176 | ID MultipleIds {
177 $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
181 cal_NAME {
182 $<str>$ = $<str>1;
184 | Variable {
185 $<str>$ = $<str>1;
190 /* End of grammar */
192 /*--------------------------------------------------------------------------*/
193 void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message)
195 yyGetParser->Error(message);