1 #include "Identifier.hpp"
2 #include <soulng/util/Unicode.hpp>
3 #include <sngcpp/parser/Template.hpp>
4 #include <sngcpp/lexer/CppLexer.hpp>
5 #include <sngcpp/lexer/CppTokens.hpp>
6
7
8
9 using namespace soulng::unicode;
10 using namespace CppTokens;
11
12 soulng::parser::Match IdentifierParser::Identifier(CppLexer& lexer)
13 {
14 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
15
16
17
18
19
20
21
22 #endif // SOULNG_PARSER_DEBUG_SUPPORT
23 soulng::parser::Match match(false);
24 soulng::parser::Match* parentMatch0 = &match;
25 {
26 int64_t pos = lexer.GetPos();
27 soulng::parser::Match match(false);
28 if (*lexer == ID)
29 {
30 ++lexer;
31 match.hit = true;
32 }
33 if (match.hit)
34 {
35 soulng::lexer::Token token = lexer.GetToken(pos);
36 {
37 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
38
39 #endif // SOULNG_PARSER_DEBUG_SUPPORT
40 return soulng::parser::Match(true, new soulng::parser::Value<std::u32string>(token.match.ToString()));
41 }
42 }
43 *parentMatch0 = match;
44 }
45 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
46
47
48
49
50
51 #endif // SOULNG_PARSER_DEBUG_SUPPORT
52 if (!match.hit)
53 {
54 match.value = nullptr;
55 }
56 return match;
57 }
58
59 soulng::parser::Match IdentifierParser::IdNode(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
60 {
61 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
62
63
64
65
66
67
68
69 #endif // SOULNG_PARSER_DEBUG_SUPPORT
70 std::unique_ptr<sngcpp::ast::Node> simpleTemplateId;
71 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>identifier;
72 soulng::parser::Match match(false);
73 soulng::parser::Match* parentMatch0 = &match;
74 {
75 int64_t save = lexer.GetPos();
76 soulng::parser::Match match(false);
77 soulng::parser::Match* parentMatch1 = &match;
78 {
79 int64_t pos = lexer.GetPos();
80 soulng::parser::Match match = TemplateParser::SimpleTemplateId(lexer, ctx);
81 simpleTemplateId.reset(static_cast<sngcpp::ast::Node*>(match.value));
82 if (match.hit)
83 {
84 {
85 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
86
87 #endif // SOULNG_PARSER_DEBUG_SUPPORT
88 return soulng::parser::Match(true, simpleTemplateId.release());
89 }
90 }
91 *parentMatch1 = match;
92 }
93 *parentMatch0 = match;
94 if (!match.hit)
95 {
96 soulng::parser::Match match(false);
97 soulng::parser::Match* parentMatch2 = &match;
98 lexer.SetPos(save);
99 {
100 soulng::parser::Match match(false);
101 soulng::parser::Match* parentMatch3 = &match;
102 {
103 int64_t pos = lexer.GetPos();
104 soulng::lexer::Span span = lexer.GetSpan();
105 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
106 identifier.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
107 if (match.hit)
108 {
109 {
110 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
111
112 #endif // SOULNG_PARSER_DEBUG_SUPPORT
113 return soulng::parser::Match(true, new sngcpp::ast::IdentifierNode(span, identifier->value));
114 }
115 }
116 *parentMatch3 = match;
117 }
118 *parentMatch2 = match;
119 }
120 *parentMatch0 = match;
121 }
122 }
123 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
124
125
126
127
128
129 #endif // SOULNG_PARSER_DEBUG_SUPPORT
130 if (!match.hit)
131 {
132 match.value = nullptr;
133 }
134 return match;
135 }
136
137 soulng::parser::Match IdentifierParser::NestedNameSpecifier(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
138 {
139 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
140
141
142
143
144
145
146
147 #endif // SOULNG_PARSER_DEBUG_SUPPORT
148 std::unique_ptr<sngcpp::ast::Node> node = std::unique_ptr<sngcpp::ast::Node>();
149 std::unique_ptr<sngcpp::ast::Node> left;
150 std::unique_ptr<sngcpp::ast::Node> right;
151 soulng::parser::Match match(false);
152 soulng::parser::Match* parentMatch0 = &match;
153 {
154 int64_t pos = lexer.GetPos();
155 soulng::parser::Match match(false);
156 soulng::parser::Match* parentMatch1 = &match;
157 {
158 soulng::parser::Match match(false);
159 soulng::parser::Match* parentMatch2 = &match;
160 {
161 soulng::parser::Match match(false);
162 soulng::parser::Match* parentMatch3 = &match;
163 {
164 soulng::parser::Match match(false);
165 soulng::parser::Match* parentMatch4 = &match;
166 {
167 int64_t pos = lexer.GetPos();
168 soulng::parser::Match match = IdentifierParser::IdNode(lexer, ctx);
169 left.reset(static_cast<sngcpp::ast::Node*>(match.value));
170 if (match.hit)
171 {
172 node.reset(left.release());
173 }
174 *parentMatch4 = match;
175 }
176 *parentMatch3 = match;
177 }
178 if (match.hit)
179 {
180 soulng::parser::Match match(false);
181 soulng::parser::Match* parentMatch5 = &match;
182 {
183 soulng::parser::Match match(false);
184 if (*lexer == COLONCOLON)
185 {
186 ++lexer;
187 match.hit = true;
188 }
189 *parentMatch5 = match;
190 }
191 *parentMatch3 = match;
192 }
193 *parentMatch2 = match;
194 }
195 if (match.hit)
196 {
197 soulng::parser::Match match(false);
198 soulng::parser::Match* parentMatch6 = &match;
199 {
200 soulng::parser::Match match(true);
201 soulng::parser::Match* parentMatch7 = &match;
202 {
203 while (true)
204 {
205 int64_t save = lexer.GetPos();
206 {
207 soulng::parser::Match match(false);
208 soulng::parser::Match* parentMatch8 = &match;
209 {
210 soulng::parser::Match match(false);
211 soulng::parser::Match* parentMatch9 = &match;
212 {
213 soulng::parser::Match match = IdentifierParser::IdNode(lexer, ctx);
214 right.reset(static_cast<sngcpp::ast::Node*>(match.value));
215 *parentMatch9 = match;
216 }
217 if (match.hit)
218 {
219 soulng::parser::Match match(false);
220 soulng::parser::Match* parentMatch10 = &match;
221 {
222 soulng::parser::Match match(false);
223 soulng::parser::Match* parentMatch11 = &match;
224 {
225 int64_t pos = lexer.GetPos();
226 soulng::lexer::Span span = lexer.GetSpan();
227 soulng::parser::Match match(false);
228 if (*lexer == COLONCOLON)
229 {
230 ++lexer;
231 match.hit = true;
232 }
233 if (match.hit)
234 {
235 node.reset(new sngcpp::ast::NestedIdNode(span, node.release(), right.release()));
236 }
237 *parentMatch11 = match;
238 }
239 *parentMatch10 = match;
240 }
241 *parentMatch9 = match;
242 }
243 *parentMatch8 = match;
244 }
245 if (match.hit)
246 {
247 *parentMatch7 = match;
248 }
249 else
250 {
251 lexer.SetPos(save);
252 break;
253 }
254 }
255 }
256 }
257 *parentMatch6 = match;
258 }
259 *parentMatch2 = match;
260 }
261 *parentMatch1 = match;
262 }
263 if (match.hit)
264 {
265 {
266 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
267
268 #endif // SOULNG_PARSER_DEBUG_SUPPORT
269 return soulng::parser::Match(true, node.release());
270 }
271 }
272 *parentMatch0 = match;
273 }
274 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
275
276
277
278
279
280 #endif // SOULNG_PARSER_DEBUG_SUPPORT
281 if (!match.hit)
282 {
283 match.value = nullptr;
284 }
285 return match;
286 }
287
288 soulng::parser::Match IdentifierParser::QualifiedIdNode(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
289 {
290 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
291
292
293
294
295
296
297
298 #endif // SOULNG_PARSER_DEBUG_SUPPORT
299 std::unique_ptr<sngcpp::ast::Node> node = std::unique_ptr<sngcpp::ast::Node>();
300 std::unique_ptr<sngcpp::ast::Node> ns1;
301 std::unique_ptr<sngcpp::ast::Node> id1;
302 std::unique_ptr<sngcpp::ast::Node> ns2;
303 std::unique_ptr<sngcpp::ast::Node> id2;
304 std::unique_ptr<sngcpp::ast::Node> id3;
305 soulng::parser::Match match(false);
306 soulng::parser::Match* parentMatch0 = &match;
307 {
308 int64_t pos = lexer.GetPos();
309 soulng::parser::Match match(false);
310 soulng::parser::Match* parentMatch1 = &match;
311 {
312 soulng::parser::Match match(false);
313 soulng::parser::Match* parentMatch2 = &match;
314 {
315 int64_t save = lexer.GetPos();
316 soulng::parser::Match match(false);
317 soulng::parser::Match* parentMatch3 = &match;
318 {
319 int64_t save = lexer.GetPos();
320 soulng::parser::Match match(false);
321 soulng::parser::Match* parentMatch4 = &match;
322 {
323 int64_t pos = lexer.GetPos();
324 soulng::lexer::Span span = lexer.GetSpan();
325 soulng::parser::Match match(false);
326 soulng::parser::Match* parentMatch5 = &match;
327 {
328 soulng::parser::Match match(false);
329 soulng::parser::Match* parentMatch6 = &match;
330 {
331 soulng::parser::Match match(false);
332 soulng::parser::Match* parentMatch7 = &match;
333 {
334 soulng::parser::Match match(false);
335 if (*lexer == COLONCOLON)
336 {
337 ++lexer;
338 match.hit = true;
339 }
340 *parentMatch7 = match;
341 }
342 if (match.hit)
343 {
344 soulng::parser::Match match(false);
345 soulng::parser::Match* parentMatch8 = &match;
346 {
347 soulng::parser::Match match(false);
348 soulng::parser::Match* parentMatch9 = &match;
349 {
350 int64_t pos = lexer.GetPos();
351 soulng::parser::Match match = IdentifierParser::NestedNameSpecifier(lexer, ctx);
352 ns1.reset(static_cast<sngcpp::ast::Node*>(match.value));
353 if (match.hit)
354 {
355 node.reset(ns1.release());
356 }
357 *parentMatch9 = match;
358 }
359 *parentMatch8 = match;
360 }
361 *parentMatch7 = match;
362 }
363 *parentMatch6 = match;
364 }
365 if (match.hit)
366 {
367 soulng::parser::Match match(false);
368 soulng::parser::Match* parentMatch10 = &match;
369 {
370 soulng::parser::Match match = IdentifierParser::IdNode(lexer, ctx);
371 id1.reset(static_cast<sngcpp::ast::Node*>(match.value));
372 *parentMatch10 = match;
373 }
374 *parentMatch6 = match;
375 }
376 *parentMatch5 = match;
377 }
378 if (match.hit)
379 {
380 node.reset(new sngcpp::ast::NestedIdNode(span, new sngcpp::ast::NestedIdNode(span, nullptr, node.release()), id1.release()));
381 }
382 *parentMatch4 = match;
383 }
384 *parentMatch3 = match;
385 if (!match.hit)
386 {
387 soulng::parser::Match match(false);
388 soulng::parser::Match* parentMatch11 = &match;
389 lexer.SetPos(save);
390 {
391 soulng::parser::Match match(false);
392 soulng::parser::Match* parentMatch12 = &match;
393 {
394 int64_t pos = lexer.GetPos();
395 soulng::lexer::Span span = lexer.GetSpan();
396 soulng::parser::Match match(false);
397 soulng::parser::Match* parentMatch13 = &match;
398 {
399 soulng::parser::Match match(false);
400 soulng::parser::Match* parentMatch14 = &match;
401 {
402 soulng::parser::Match match(false);
403 soulng::parser::Match* parentMatch15 = &match;
404 {
405 int64_t pos = lexer.GetPos();
406 soulng::parser::Match match = IdentifierParser::NestedNameSpecifier(lexer, ctx);
407 ns2.reset(static_cast<sngcpp::ast::Node*>(match.value));
408 if (match.hit)
409 {
410 node.reset(ns2.release());
411 }
412 *parentMatch15 = match;
413 }
414 *parentMatch14 = match;
415 }
416 if (match.hit)
417 {
418 soulng::parser::Match match(false);
419 soulng::parser::Match* parentMatch16 = &match;
420 {
421 soulng::parser::Match match = IdentifierParser::IdNode(lexer, ctx);
422 id2.reset(static_cast<sngcpp::ast::Node*>(match.value));
423 *parentMatch16 = match;
424 }
425 *parentMatch14 = match;
426 }
427 *parentMatch13 = match;
428 }
429 if (match.hit)
430 {
431 node.reset(new sngcpp::ast::NestedIdNode(span, node.release(), id2.release()));
432 }
433 *parentMatch12 = match;
434 }
435 *parentMatch11 = match;
436 }
437 *parentMatch3 = match;
438 }
439 }
440 *parentMatch2 = match;
441 if (!match.hit)
442 {
443 soulng::parser::Match match(false);
444 soulng::parser::Match* parentMatch17 = &match;
445 lexer.SetPos(save);
446 {
447 soulng::parser::Match match(false);
448 soulng::parser::Match* parentMatch18 = &match;
449 {
450 int64_t pos = lexer.GetPos();
451 soulng::parser::Match match = IdentifierParser::IdNode(lexer, ctx);
452 id3.reset(static_cast<sngcpp::ast::Node*>(match.value));
453 if (match.hit)
454 {
455 node.reset(id3.release());
456 }
457 *parentMatch18 = match;
458 }
459 *parentMatch17 = match;
460 }
461 *parentMatch2 = match;
462 }
463 }
464 *parentMatch1 = match;
465 }
466 if (match.hit)
467 {
468 {
469 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
470
471 #endif // SOULNG_PARSER_DEBUG_SUPPORT
472 return soulng::parser::Match(true, node.release());
473 }
474 }
475 *parentMatch0 = match;
476 }
477 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
478
479
480
481
482
483 #endif // SOULNG_PARSER_DEBUG_SUPPORT
484 if (!match.hit)
485 {
486 match.value = nullptr;
487 }
488 return match;
489 }