GCC Code Coverage Report


Directory: src/
File: src/frontend/tree.cpp
Date: 2025-10-15 09:43:47
Exec Total Coverage
Lines: 1417 1686 84.0%
Functions: 309 403 76.7%
Branches: 20 22 90.9%

Line Branch Exec Source
1 #include <gyoji-frontend.hpp>
2 #include <gyoji-misc/jstring.hpp>
3
4 using namespace Gyoji::context;
5 using namespace Gyoji::frontend;
6 using namespace Gyoji::frontend::ast;
7 using namespace Gyoji::frontend::tree;
8
9 ///////////////////////////////////////////////////
10 // Terminal
11 ///////////////////////////////////////////////////
12 32188 Terminal::Terminal(const Token & _token)
13 32188 : SyntaxNode(_token.get_type(), this, _token.get_source_ref())
14 32188 , token(_token)
15 32188 , identifier_type(IDENTIFIER_UNCATEGORIZED)
16 64376 , ns2_entity(nullptr)
17
18 32188 {}
19 27550 Terminal::~Terminal()
20 27550 {}
21 const TokenID &
22 15976 Terminal::get_type() const
23 15976 { return token.get_type(); }
24 const std::string &
25 26182 Terminal::get_value() const
26 26182 { return token.get_value(); }
27 const SourceReference &
28 Terminal::get_terminal_source_ref() const
29 { return token.get_source_ref(); }
30
31 std::string
32 5062 Terminal::get_fully_qualified_name() const
33 {
34
2/2
✓ Branch 0 taken 5030 times.
✓ Branch 1 taken 32 times.
5062 if (identifier_type == IDENTIFIER_GLOBAL_SCOPE) {
35 5030 return ns2_entity->get_fully_qualified_name();
36 }
37 32 return token.get_value();
38 }
39 std::string
40 3574 Terminal::get_name() const
41 {
42
2/2
✓ Branch 0 taken 3560 times.
✓ Branch 1 taken 14 times.
3574 if (identifier_type == IDENTIFIER_GLOBAL_SCOPE) {
43 3560 return ns2_entity->get_name();
44 }
45 14 return token.get_value();
46 }
47 const Terminal::IdentifierType &
48 2484 Terminal::get_identifier_type() const
49 2484 { return identifier_type; }
50
51 void
52 400 Terminal::set_identifier_type(IdentifierType _identifier_type)
53 400 { identifier_type = _identifier_type; }
54
55 void
56 17440 Terminal::set_ns2_entity(Gyoji::frontend::namespaces::NS2Entity *_ns2_entity)
57 {
58
2/2
✓ Branch 0 taken 13044 times.
✓ Branch 1 taken 4396 times.
17440 if (_ns2_entity != nullptr) {
59 13044 identifier_type = IDENTIFIER_GLOBAL_SCOPE;
60 }
61 17440 ns2_entity = _ns2_entity;
62 17440 }
63
64 Gyoji::frontend::namespaces::NS2Entity *
65 312 Terminal::get_ns2_entity() const
66 312 { return ns2_entity; }
67
68 ///////////////////////////////////////////////////
69 // TerminalNonSyntax
70 ///////////////////////////////////////////////////
71 26348 TerminalNonSyntax::TerminalNonSyntax(TerminalNonSyntax::Type _type, const Token & _token)
72 26348 : type(_type)
73 26348 , token(_token)
74 26348 {}
75 22398 TerminalNonSyntax::~TerminalNonSyntax()
76 22398 {}
77 const TerminalNonSyntax::Type &
78 7900 TerminalNonSyntax::get_type() const
79 {
80 7900 return type;
81 }
82 const std::string &
83 7900 TerminalNonSyntax::get_data() const
84 {
85 7900 return token.get_value();
86 }
87
88 ///////////////////////////////////////////////////
89 // AccessQualifier
90 ///////////////////////////////////////////////////
91 3422 AccessQualifier::AccessQualifier(const Gyoji::context::SourceReference & _source_ref)
92 6844 : SyntaxNode(NONTERMINAL_access_qualifier, this, _source_ref)
93 3422 , type(Gyoji::frontend::tree::AccessQualifier::AccessQualifierType::UNSPECIFIED)
94 3422 , qualifier(nullptr)
95 3422 {}
96 182 AccessQualifier::AccessQualifier(Gyoji::owned<Terminal> _qualifier)
97 546 : SyntaxNode(NONTERMINAL_access_qualifier, this, _qualifier->get_source_ref())
98 182 , qualifier(std::move(_qualifier))
99 {
100
2/2
✓ Branch 3 taken 86 times.
✓ Branch 4 taken 96 times.
182 if (qualifier->get_value() == "volatile") {
101 86 type = Gyoji::frontend::tree::AccessQualifier::AccessQualifierType::VOLATILE;
102 }
103
1/2
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
96 else if (qualifier->get_value() == "const") {
104 96 type = Gyoji::frontend::tree::AccessQualifier::AccessQualifierType::CONST;
105 }
106 else {
107 type = Gyoji::frontend::tree::AccessQualifier::AccessQualifierType::UNSPECIFIED;
108 }
109 182 add_child(*qualifier);
110 182 }
111 3604 AccessQualifier::~AccessQualifier()
112 3604 {}
113 const AccessQualifier::AccessQualifierType &
114 12 AccessQualifier::get_type() const
115 12 { return type; }
116
117 ///////////////////////////////////////////////////
118 // AccessModifier
119 ///////////////////////////////////////////////////
120 298 AccessModifier::AccessModifier(Gyoji::owned<Terminal> _modifier)
121 894 : SyntaxNode(NONTERMINAL_access_modifier, this, _modifier->get_source_ref())
122 298 , modifier(std::move(_modifier))
123 {
124
2/2
✓ Branch 3 taken 230 times.
✓ Branch 4 taken 68 times.
298 if (modifier->get_value() == "public") {
125 230 type = Gyoji::frontend::tree::AccessModifier::AccessModifierType::PUBLIC;
126 }
127
2/2
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 50 times.
68 else if (modifier->get_value() == "protected") {
128 18 type = Gyoji::frontend::tree::AccessModifier::AccessModifierType::PROTECTED;
129 }
130
1/2
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
50 else if (modifier->get_value() == "private") {
131 50 type = Gyoji::frontend::tree::AccessModifier::AccessModifierType::PRIVATE;
132 }
133 else {
134 type = Gyoji::frontend::tree::AccessModifier::AccessModifierType::PUBLIC;
135 }
136 298 add_child(*modifier);
137 298 }
138 1300 AccessModifier::AccessModifier(const Gyoji::context::SourceReference & _source_ref)
139 2600 : SyntaxNode(NONTERMINAL_access_modifier, this, _source_ref)
140 1300 , type(Gyoji::frontend::tree::AccessModifier::AccessModifierType::PUBLIC)
141 1300 , modifier(nullptr)
142 1300 {}
143 1598 AccessModifier::~AccessModifier()
144 1598 {}
145 const AccessModifier::AccessModifierType &
146 12 AccessModifier::get_type() const
147 {
148 12 return type;
149 }
150 ///////////////////////////////////////////////////
151 // UnsafeModifier
152 ///////////////////////////////////////////////////
153 788 UnsafeModifier::UnsafeModifier(const Gyoji::context::SourceReference & _source_ref)
154 1576 : SyntaxNode(NONTERMINAL_unsafe_modifier, this, _source_ref)
155 788 , unsafe_token(nullptr)
156 788 {}
157 28 UnsafeModifier::UnsafeModifier(Gyoji::owned<Terminal> _unsafe_token)
158 84 : SyntaxNode(NONTERMINAL_unsafe_modifier, this, _unsafe_token->get_source_ref())
159 28 , unsafe_token(std::move(_unsafe_token))
160 {
161 28 add_child(*unsafe_token);
162 28 }
163 816 UnsafeModifier::~UnsafeModifier()
164 816 {}
165 bool
166 6 UnsafeModifier::is_unsafe() const
167 {
168 6 return unsafe_token.get() != nullptr;
169 }
170
171 ///////////////////////////////////////////////////
172 // TypeName
173 ///////////////////////////////////////////////////
174 3028 TypeName::TypeName(Gyoji::owned<Terminal> _type_name)
175 9084 : SyntaxNode(NONTERMINAL_type_name, this, _type_name->get_source_ref())
176 3028 , m_is_expression(false)
177 3028 , type_name(std::move(_type_name))
178 3028 , typeof_token(nullptr)
179 3028 , paren_l_token(nullptr)
180 3028 , expression(nullptr)
181 6056 , paren_r_token(nullptr)
182 {
183 3028 add_child(*type_name);
184 3028 }
185 16 TypeName::TypeName(Gyoji::owned<Terminal> _typeof_token,
186 Gyoji::owned<Terminal> _paren_l_token,
187 Gyoji::owned<Expression> _expression,
188 Gyoji::owned<Terminal> _paren_r_token
189 16 )
190 48 : SyntaxNode(NONTERMINAL_type_name, this, _typeof_token->get_source_ref())
191 16 , m_is_expression(true)
192 16 , type_name(nullptr)
193 16 , typeof_token(std::move(_typeof_token))
194 16 , paren_l_token(std::move(_paren_l_token))
195 16 , expression(std::move(_expression))
196 32 , paren_r_token(std::move(_paren_r_token))
197 {
198 16 add_child(*typeof_token);
199 16 add_child(*paren_l_token);
200 16 add_child(*expression);
201 16 add_child(*paren_r_token);
202 16 }
203 3044 TypeName::~TypeName()
204 3044 {}
205 bool
206 2034 TypeName::is_expression() const
207 2034 { return m_is_expression; }
208 std::string
209 2034 TypeName::get_name() const
210 2034 { return type_name->get_fully_qualified_name(); }
211 const SourceReference &
212 TypeName::get_name_source_ref() const
213 { return type_name->get_source_ref(); }
214 const Expression &
215 TypeName::get_expression() const
216 { return *expression; }
217 ///////////////////////////////////////////////////
218 // TypeName
219 ///////////////////////////////////////////////////
220 24 TypeSpecifierCallArgs::TypeSpecifierCallArgs(const Gyoji::context::SourceReference & _source_ref)
221 24 : SyntaxNode(NONTERMINAL_type_specifier_call_args, this, _source_ref)
222 24 {}
223 24 TypeSpecifierCallArgs::~TypeSpecifierCallArgs()
224 24 {}
225 void
226 24 TypeSpecifierCallArgs::add_argument(Gyoji::owned<TypeSpecifier> _argument)
227 {
228 24 add_child(*_argument);
229 24 arguments.push_back(std::move(_argument));
230 24 }
231 void
232 8 TypeSpecifierCallArgs::add_argument(Gyoji::owned<Terminal> _comma_token, Gyoji::owned<TypeSpecifier> _argument)
233 {
234 8 add_child(*_comma_token);
235 8 add_child(*_argument);
236 8 comma_list.push_back(std::move(_comma_token));
237 8 arguments.push_back(std::move(_argument));
238 8 }
239 const std::vector<Gyoji::owned<TypeSpecifier>> &
240 TypeSpecifierCallArgs::get_arguments() const
241 { return arguments; }
242
243 ///////////////////////////////////////////////////
244 3044 TypeSpecifierSimple::TypeSpecifierSimple(
245 Gyoji::owned<AccessQualifier> _access_qualifier,
246 Gyoji::owned<TypeName> _type_name
247 3044 )
248 9132 : SyntaxNode(NONTERMINAL_type_specifier_simple, this, _access_qualifier->get_source_ref())
249 3044 , access_qualifier(std::move(_access_qualifier))
250 6088 , type_name(std::move(_type_name))
251 {
252 3044 add_child(*access_qualifier);
253 3044 add_child(*type_name);
254 3044 }
255 3044 TypeSpecifierSimple::~TypeSpecifierSimple()
256 3044 {}
257 const AccessQualifier &
258 8 TypeSpecifierSimple::get_access_qualifier() const
259 8 { return *access_qualifier; }
260 const TypeName &
261 2034 TypeSpecifierSimple::get_type_name() const
262 2034 { return *type_name; }
263 ///////////////////////////////////////////////////
264 24 TypeSpecifierTemplate::TypeSpecifierTemplate(
265 Gyoji::owned<TypeSpecifier> _type_specifier,
266 Gyoji::owned<Terminal> _paren_l_token,
267 Gyoji::owned<TypeSpecifierCallArgs> _type_specifier_call_args,
268 Gyoji::owned<Terminal> _paren_r_token
269 24 )
270 72 : SyntaxNode(NONTERMINAL_type_specifier_template, this, _type_specifier->get_source_ref())
271 24 , type_specifier(std::move(_type_specifier))
272 24 , paren_l_token(std::move(_paren_l_token))
273 24 , type_specifier_call_args(std::move(_type_specifier_call_args))
274 48 , paren_r_token(std::move(_paren_r_token))
275 {
276 24 add_child(*type_specifier);
277 24 add_child(*paren_l_token);
278 24 add_child(*type_specifier_call_args);
279 24 add_child(*paren_r_token);
280 24 }
281 24 TypeSpecifierTemplate::~TypeSpecifierTemplate()
282 24 {}
283 const TypeSpecifier &
284 TypeSpecifierTemplate::get_type() const
285 { return *type_specifier; }
286 const TypeSpecifierCallArgs &
287 TypeSpecifierTemplate::get_args() const
288 { return *type_specifier_call_args; }
289 ///////////////////////////////////////////////////
290 8 TypeSpecifierFunctionPointer::TypeSpecifierFunctionPointer(
291 Gyoji::owned<TypeSpecifier> _type_specifier,
292 Gyoji::owned<Terminal> _paren_l1_token,
293 Gyoji::owned<Terminal> _star_token,
294 Gyoji::owned<Terminal> _identifier_token,
295 Gyoji::owned<Terminal> _paren_r1_token,
296 Gyoji::owned<Terminal> _paren_l2_token,
297 Gyoji::owned<FunctionDefinitionArgList> _function_definition_arg_list,
298 Gyoji::owned<Terminal> _paren_r2_token
299 8 )
300 24 : SyntaxNode(NONTERMINAL_type_specifier_function_pointer, this, _type_specifier->get_source_ref())
301 8 , type_specifier(std::move(_type_specifier))
302 8 , paren_l1_token(std::move(_paren_l1_token))
303 8 , star_token(std::move(_star_token))
304 8 , identifier_token(std::move(_identifier_token))
305 8 , paren_r1_token(std::move(_paren_r1_token))
306 8 , paren_l2_token(std::move(_paren_l2_token))
307 8 , function_definition_arg_list(std::move(_function_definition_arg_list))
308 16 , paren_r2_token(std::move(_paren_r2_token))
309 {
310 8 add_child(*type_specifier);
311 8 add_child(*paren_l1_token);
312 8 add_child(*star_token);
313 8 add_child(*identifier_token);
314 8 add_child(*paren_r1_token);
315 8 add_child(*paren_l2_token);
316 8 add_child(*function_definition_arg_list);
317 8 add_child(*paren_r2_token);
318 8 }
319 8 TypeSpecifierFunctionPointer::~TypeSpecifierFunctionPointer()
320 8 {}
321 const TypeSpecifier & TypeSpecifierFunctionPointer::get_return_type() const
322 { return *type_specifier; }
323 const std::string &
324 TypeSpecifierFunctionPointer::get_name() const
325 { return identifier_token->get_value(); }
326 const SourceReference &
327 TypeSpecifierFunctionPointer::get_name_source_ref() const
328 { return identifier_token->get_source_ref(); }
329 const FunctionDefinitionArgList &
330 TypeSpecifierFunctionPointer::get_args() const
331 { return *function_definition_arg_list; }
332 ///////////////////////////////////////////////////
333 510 TypeSpecifierPointerTo::TypeSpecifierPointerTo(
334 Gyoji::owned<TypeSpecifier> _type_specifier,
335 Gyoji::owned<Terminal> _star_token,
336 Gyoji::owned<AccessQualifier> _access_qualifier
337 510 )
338 1530 : SyntaxNode(NONTERMINAL_type_specifier_pointer_to, this, _type_specifier->get_source_ref())
339 510 , type_specifier(std::move(_type_specifier))
340 510 , star_token(std::move(_star_token))
341 1020 , access_qualifier(std::move(_access_qualifier))
342 {
343 510 add_child(*type_specifier);
344 510 add_child(*star_token);
345 510 add_child(*access_qualifier);
346 510 }
347 510 TypeSpecifierPointerTo::~TypeSpecifierPointerTo()
348 510 {}
349 const TypeSpecifier &
350 142 TypeSpecifierPointerTo::get_type_specifier() const
351 142 { return *type_specifier; }
352 const AccessQualifier &
353 2 TypeSpecifierPointerTo::get_access_qualifier() const
354 2 { return *access_qualifier; }
355 ///////////////////////////////////////////////////
356 50 TypeSpecifierReferenceTo::TypeSpecifierReferenceTo(
357 Gyoji::owned<TypeSpecifier> _type_specifier,
358 Gyoji::owned<Terminal> _andpersand_token,
359 Gyoji::owned<AccessQualifier> _access_qualifier
360 50 )
361 150 : SyntaxNode(NONTERMINAL_type_specifier_reference_to, this, _type_specifier->get_source_ref())
362 50 , type_specifier(std::move(_type_specifier))
363 50 , andpersand_token(std::move(_andpersand_token))
364 100 , access_qualifier(std::move(_access_qualifier))
365 {
366 50 add_child(*type_specifier);
367 50 add_child(*andpersand_token);
368 50 add_child(*access_qualifier);
369 50 }
370 50 TypeSpecifierReferenceTo::~TypeSpecifierReferenceTo()
371 50 {}
372 const TypeSpecifier &
373 10 TypeSpecifierReferenceTo::get_type_specifier() const
374 10 { return *type_specifier; }
375 const AccessQualifier &
376 2 TypeSpecifierReferenceTo::get_access_qualifier() const
377 2 { return *access_qualifier; }
378 ///////////////////////////////////////////////////
379 10 TypeSpecifierArray::TypeSpecifierArray(
380 Gyoji::owned<TypeSpecifier> _type_specifier,
381 Gyoji::owned<Terminal> _bracket_l_token,
382 Gyoji::owned<Terminal> _literal_int_token,
383 Gyoji::owned<Terminal> _bracket_r_token
384 10 )
385 30 : SyntaxNode(NONTERMINAL_type_specifier_array, this, _type_specifier->get_source_ref())
386 10 , type_specifier(std::move(_type_specifier))
387 10 , bracket_l_token(std::move(_bracket_l_token))
388 10 , literal_int_token(std::move(_literal_int_token))
389 20 , bracket_r_token(std::move(_bracket_r_token))
390 {
391 10 add_child(*type_specifier);
392 10 add_child(*bracket_l_token);
393 10 add_child(*literal_int_token);
394 10 add_child(*bracket_r_token);
395 10 }
396 /**
397 * Destructor, nothing special.
398 */
399 10 TypeSpecifierArray::~TypeSpecifierArray()
400 10 {}
401 /**
402 * Returns the type that is accessed behind this pointer.
403 */
404 const TypeSpecifier &
405 2 TypeSpecifierArray::get_type_specifier() const
406 2 { return *type_specifier; }
407
408 const Terminal &
409 2 TypeSpecifierArray::get_literal_int_token() const
410 2 { return *literal_int_token; }
411
412 ///////////////////////////////////////////////////
413 3646 TypeSpecifier::TypeSpecifier(TypeSpecifier::TypeSpecifierType _type, const SyntaxNode & _sn)
414 7292 : SyntaxNode(NONTERMINAL_type_specifier, this, _sn.get_source_ref())
415 3646 , type(std::move(_type))
416 {
417 3646 add_child(_sn);
418 3646 }
419 3646 TypeSpecifier::~TypeSpecifier()
420 3646 {}
421 const TypeSpecifier::TypeSpecifierType &
422 2204 TypeSpecifier::get_type() const
423 2204 { return type; }
424
425 ///////////////////////////////////////////////////
426 1094 FunctionDefinitionArg::FunctionDefinitionArg(
427 Gyoji::owned<TypeSpecifier> _type_specifier,
428 Gyoji::owned<Terminal> _identifier_token
429 1094 )
430 3282 : SyntaxNode(NONTERMINAL_function_definition_arg, this, _type_specifier->get_source_ref())
431 1094 , type_specifier(std::move(_type_specifier))
432 2188 , identifier_token(std::move(_identifier_token))
433 {
434 1094 add_child(*type_specifier);
435 1094 add_child(*identifier_token);
436 1094 }
437 1094 FunctionDefinitionArg::~FunctionDefinitionArg()
438 1094 {}
439 const TypeSpecifier &
440 2154 FunctionDefinitionArg::get_type_specifier() const
441 2154 { return *type_specifier; }
442 const Terminal &
443 1594 FunctionDefinitionArg::get_identifier() const
444 1594 { return *identifier_token; }
445
446 ///////////////////////////////////////////////////
447 702 FunctionDefinitionArgList::FunctionDefinitionArgList(const Gyoji::context::SourceReference & _source_ref)
448 702 : SyntaxNode(NONTERMINAL_function_definition_arg_list, this, _source_ref)
449 702 {}
450 702 FunctionDefinitionArgList::~FunctionDefinitionArgList()
451 702 {}
452 const std::vector<Gyoji::owned<FunctionDefinitionArg>> &
453 590 FunctionDefinitionArgList::get_arguments() const
454 590 { return arguments; }
455 void
456 1094 FunctionDefinitionArgList::add_argument(Gyoji::owned<FunctionDefinitionArg> _argument)
457 {
458 1094 add_child(*_argument);
459 1094 arguments.push_back(std::move(_argument));
460 1094 }
461 void
462 502 FunctionDefinitionArgList::add_comma(Gyoji::owned<Terminal> _comma)
463 {
464 502 add_child(*_comma);
465 502 commas.push_back(std::move(_comma));
466 502 }
467
468
469 ///////////////////////////////////////////////////
470 668 FileStatementFunctionDeclStart::FileStatementFunctionDeclStart(
471 Gyoji::owned<AccessModifier> _access_modifier,
472 Gyoji::owned<UnsafeModifier> _unsafe_modifier,
473 Gyoji::owned<TypeSpecifier> _type_specifier,
474 Gyoji::owned<Terminal> _name
475 668 )
476 2004 : SyntaxNode(NONTERMINAL_function_decl_start, this, _name->get_source_ref())
477 668 , access_modifier(std::move(_access_modifier))
478 668 , unsafe_modifier(std::move(_unsafe_modifier))
479 668 , type_specifier(std::move(_type_specifier))
480 1336 , name(std::move(_name))
481 {
482 668 add_child(*access_modifier);
483 668 add_child(*unsafe_modifier);
484 668 add_child(*type_specifier);
485 668 add_child(*name);
486 668 }
487
488 668 FileStatementFunctionDeclStart::~FileStatementFunctionDeclStart()
489 668 {}
490
491 const AccessModifier &
492 FileStatementFunctionDeclStart::get_access_modifier() const
493 { return *access_modifier; }
494
495 const UnsafeModifier &
496 4 FileStatementFunctionDeclStart::get_unsafe_modifier() const
497 4 { return *unsafe_modifier; }
498
499 const TypeSpecifier &
500 584 FileStatementFunctionDeclStart::get_type_specifier() const
501 584 { return *type_specifier;}
502
503 const Terminal &
504 850 FileStatementFunctionDeclStart::get_name() const
505 850 { return *name; }
506
507 ///////////////////////////////////////////////////
508
509 224 FileStatementFunctionDeclaration::FileStatementFunctionDeclaration(
510 Gyoji::owned<FileStatementFunctionDeclStart> _start,
511 Gyoji::owned<Terminal> _paren_l,
512 Gyoji::owned<FunctionDefinitionArgList> _arguments,
513 Gyoji::owned<Terminal> _paren_r,
514 Gyoji::owned<Terminal> _semicolon
515 224 )
516 672 : SyntaxNode(NONTERMINAL_file_statement_function_declaration, this, _start->get_source_ref())
517 224 , start(std::move(_start))
518 224 , paren_l(std::move(_paren_l))
519 224 , arguments(std::move(_arguments))
520 224 , paren_r(std::move(_paren_r))
521 448 , semicolon(std::move(_semicolon))
522 {
523 224 add_child(*start);
524 224 add_child(*paren_l);
525 224 add_child(*arguments);
526 224 add_child(*paren_r);
527 224 add_child(*semicolon);
528 224 }
529 224 FileStatementFunctionDeclaration::~FileStatementFunctionDeclaration()
530 224 {}
531 const AccessModifier &
532 FileStatementFunctionDeclaration::get_access_modifier() const
533 { return start->get_access_modifier(); }
534 const UnsafeModifier &
535 4 FileStatementFunctionDeclaration::get_unsafe_modifier() const
536 4 { return start->get_unsafe_modifier(); }
537 const TypeSpecifier &
538 52 FileStatementFunctionDeclaration::get_return_type() const
539 52 { return start->get_type_specifier(); }
540 const Terminal &
541 52 FileStatementFunctionDeclaration::get_name() const
542 52 { return start->get_name(); }
543 const FunctionDefinitionArgList &
544 56 FileStatementFunctionDeclaration::get_arguments() const
545 56 { return *arguments; }
546
547
548 ///////////////////////////////////////////////////
549 496 InitializerExpression::InitializerExpression(
550 const SourceReference & _src_ref
551 496 )
552 992 : SyntaxNode(NONTERMINAL_initializer_expression, this, _src_ref)
553 496 , equals_token(nullptr)
554 496 , expression(nullptr)
555 496 {}
556
557 20 InitializerExpression::InitializerExpression(
558 Gyoji::owned<Terminal> _equals_token,
559 Gyoji::owned<Expression> _expression
560 20 )
561 60 : SyntaxNode(NONTERMINAL_initializer_expression, this, _expression->get_source_ref())
562 20 , equals_token(std::move(_equals_token))
563 40 , expression(std::move(_expression))
564 {
565 20 add_child(*equals_token);
566 20 add_child(*expression);
567 20 }
568 516 InitializerExpression::~InitializerExpression()
569 516 {}
570
571 bool
572 308 InitializerExpression::has_expression() const
573 308 { return expression != nullptr; }
574
575 const Expression &
576 4 InitializerExpression::get_expression() const
577 4 { return *expression; }
578
579 ///////////////////////////////////////////////////
580 516 StatementVariableDeclaration::StatementVariableDeclaration(
581 Gyoji::owned<TypeSpecifier> _type_specifier,
582 Gyoji::owned<Terminal> _identifier_token,
583 Gyoji::owned<InitializerExpression> _initializer,
584 Gyoji::owned<Terminal> _semicolon_token
585 516 )
586 1548 : SyntaxNode(NONTERMINAL_statement_variable_declaration, this, _type_specifier->get_source_ref())
587 516 , type_specifier(std::move(_type_specifier))
588 516 , identifier_token(std::move(_identifier_token))
589 516 , initializer(std::move(_initializer))
590 1548 , semicolon_token(std::move(_semicolon_token))
591 {
592 516 add_child(*type_specifier);
593 516 add_child(*identifier_token);
594 516 add_child(*initializer);
595 516 add_child(*semicolon_token);
596 516 }
597 516 StatementVariableDeclaration::~StatementVariableDeclaration()
598 516 {}
599 const TypeSpecifier &
600 308 StatementVariableDeclaration::get_type_specifier() const
601 308 { return *type_specifier;}
602 const Terminal &
603 928 StatementVariableDeclaration::get_identifier() const
604 928 { return *identifier_token; }
605 const InitializerExpression &
606 308 StatementVariableDeclaration::get_initializer_expression() const
607 308 { return *initializer;}
608 ///////////////////////////////////////////////////
609 22 StatementBlock::StatementBlock(
610 Gyoji::owned<UnsafeModifier> _unsafe_modifier,
611 Gyoji::owned<ScopeBody> _scope_body
612 22 )
613 66 : SyntaxNode(NONTERMINAL_statement_block, this, _unsafe_modifier->get_source_ref())
614 22 , unsafe_modifier(std::move(_unsafe_modifier))
615 44 , scope_body(std::move(_scope_body))
616 {
617 22 add_child(*unsafe_modifier);
618 22 add_child(*scope_body);
619 22 }
620 22 StatementBlock::~StatementBlock()
621 22 {}
622 const UnsafeModifier &
623 2 StatementBlock::get_unsafe_modifier() const
624 2 { return *unsafe_modifier; }
625 const ScopeBody &
626 10 StatementBlock::get_scope_body() const
627 10 { return *scope_body; }
628 ///////////////////////////////////////////////////
629 1918 StatementExpression::StatementExpression(
630 Gyoji::owned<Expression> _expression,
631 Gyoji::owned<Terminal> _semicolon_token
632 1918 )
633 5754 : SyntaxNode(NONTERMINAL_statement_expression, this, _expression->get_source_ref())
634 1918 , expression(std::move(_expression))
635 3836 , semicolon_token(std::move(_semicolon_token))
636 {
637 1918 add_child(*expression);
638 1918 add_child(*semicolon_token);
639 1918 }
640 1918 StatementExpression::~StatementExpression()
641 1918 {}
642 const Expression &
643 446 StatementExpression::get_expression() const
644 446 { return *expression; }
645 ///////////////////////////////////////////////////
646 72 StatementIfElse::StatementIfElse(
647 Gyoji::owned<Terminal> _if_token,
648 Gyoji::owned<Terminal> _paren_l_token,
649 Gyoji::owned<Expression> _expression,
650 Gyoji::owned<Terminal> _paren_r_token,
651 Gyoji::owned<ScopeBody> _if_scope_body,
652 Gyoji::owned<Terminal> _else_token,
653 Gyoji::owned<ScopeBody> _else_scope_body
654 72 )
655 216 : SyntaxNode(NONTERMINAL_statement_ifelse, this, _if_token->get_source_ref())
656 72 , m_has_else(true)
657 72 , m_has_else_if(false)
658 72 , if_token(std::move(_if_token))
659 72 , paren_l_token(std::move(_paren_l_token))
660 72 , expression(std::move(_expression))
661 72 , paren_r_token(std::move(_paren_r_token))
662 72 , if_scope_body(std::move(_if_scope_body))
663 72 , else_token(std::move(_else_token))
664 144 , else_scope_body(std::move(_else_scope_body))
665 {
666 72 add_child(*if_token);
667 72 add_child(*paren_l_token);
668 72 add_child(*expression);
669 72 add_child(*paren_r_token);
670 72 add_child(*if_scope_body);
671 72 add_child(*else_token);
672 72 add_child(*else_scope_body);
673 72 }
674 32 StatementIfElse::StatementIfElse(
675 Gyoji::owned<Terminal> _if_token,
676 Gyoji::owned<Terminal> _paren_l_token,
677 Gyoji::owned<Expression> _expression,
678 Gyoji::owned<Terminal> _paren_r_token,
679 Gyoji::owned<ScopeBody> _if_scope_body,
680 Gyoji::owned<Terminal> _else_token,
681 Gyoji::owned<StatementIfElse> _else_if
682 32 )
683 96 : SyntaxNode(NONTERMINAL_statement_ifelse, this, _if_token->get_source_ref())
684 32 , m_has_else(false)
685 32 , m_has_else_if(true)
686 32 , if_token(std::move(_if_token))
687 32 , paren_l_token(std::move(_paren_l_token))
688 32 , expression(std::move(_expression))
689 32 , paren_r_token(std::move(_paren_r_token))
690 32 , if_scope_body(std::move(_if_scope_body))
691 32 , else_token(std::move(_else_token))
692 32 , else_scope_body(nullptr)
693 64 , else_if(std::move(_else_if))
694 {
695 32 add_child(*if_token);
696 32 add_child(*paren_l_token);
697 32 add_child(*expression);
698 32 add_child(*paren_r_token);
699 32 add_child(*if_scope_body);
700 32 add_child(*else_token);
701 32 add_child(*else_if);
702 32 }
703 114 StatementIfElse::StatementIfElse(
704 Gyoji::owned<Terminal> _if_token,
705 Gyoji::owned<Terminal> _paren_l_token,
706 Gyoji::owned<Expression> _expression,
707 Gyoji::owned<Terminal> _paren_r_token,
708 Gyoji::owned<ScopeBody> _if_scope_body
709 114 )
710 342 : SyntaxNode(NONTERMINAL_statement_ifelse, this, _if_token->get_source_ref())
711 114 , m_has_else(false)
712 114 , m_has_else_if(false)
713 114 , if_token(std::move(_if_token))
714 114 , paren_l_token(std::move(_paren_l_token))
715 114 , expression(std::move(_expression))
716 114 , paren_r_token(std::move(_paren_r_token))
717 114 , if_scope_body(std::move(_if_scope_body))
718 114 , else_token(nullptr)
719 228 , else_scope_body(nullptr)
720 {
721 114 add_child(*if_token);
722 114 add_child(*paren_l_token);
723 114 add_child(*expression);
724 114 add_child(*paren_r_token);
725 114 add_child(*if_scope_body);
726 114 }
727 218 StatementIfElse::~StatementIfElse()
728 218 {}
729 bool
730 68 StatementIfElse::has_else() const
731 68 { return m_has_else; }
732 bool
733 52 StatementIfElse::has_else_if() const
734 52 { return m_has_else_if; }
735 const Expression &
736 34 StatementIfElse::get_expression() const
737 34 { return *expression; }
738 const ScopeBody &
739 68 StatementIfElse::get_if_scope_body() const
740 68 { return *if_scope_body; }
741 const ScopeBody &
742 16 StatementIfElse::get_else_scope_body() const
743 16 { return *else_scope_body; }
744 const StatementIfElse &
745 StatementIfElse::get_else_if() const
746 { return *else_if;}
747 ///////////////////////////////////////////////////
748 34 StatementWhile::StatementWhile(
749 Gyoji::owned<Terminal> _while_token,
750 Gyoji::owned<Terminal> _paren_l_token,
751 Gyoji::owned<Expression> _expression,
752 Gyoji::owned<Terminal> _paren_r_token,
753 Gyoji::owned<ScopeBody> _scope_body
754 34 )
755 102 : SyntaxNode(NONTERMINAL_statement_while, this, _while_token->get_source_ref())
756 34 , while_token(std::move(_while_token))
757 34 , paren_l_token(std::move(_paren_l_token))
758 34 , expression(std::move(_expression))
759 34 , paren_r_token(std::move(_paren_r_token))
760 68 , scope_body(std::move(_scope_body))
761 {
762 34 add_child(*while_token);
763 34 add_child(*paren_l_token);
764 34 add_child(*expression);
765 34 add_child(*paren_r_token);
766 34 add_child(*scope_body);
767 34 }
768 34 StatementWhile::~StatementWhile()
769 34 {}
770 const Expression &
771 2 StatementWhile::get_expression() const
772 2 { return *expression; }
773 const ScopeBody &
774 4 StatementWhile::get_scope_body() const
775 4 { return *scope_body; }
776 ///////////////////////////////////////////////////
777 StatementFor::StatementFor(
778 Gyoji::owned<Terminal> _for_token,
779 Gyoji::owned<Terminal> _paren_l_token,
780 Gyoji::owned<Expression> _expression_initial,
781 Gyoji::owned<Terminal> _semicolon_initial,
782 Gyoji::owned<Expression> _expression_termination,
783 Gyoji::owned<Terminal> _semicolon_termination,
784 Gyoji::owned<Expression> _expression_increment,
785 Gyoji::owned<Terminal> _paren_r_token,
786 Gyoji::owned<ScopeBody> _scope_body
787 )
788 : SyntaxNode(NONTERMINAL_statement_for, this, _for_token->get_source_ref())
789 , is_declaration_initializer(false)
790 , for_token(std::move(_for_token))
791 , paren_l_token(std::move(_paren_l_token))
792 , type_specifier(nullptr)
793 , identifier_token(nullptr)
794 , assignment_token(nullptr)
795 , expression_initial(std::move(_expression_initial))
796 , semicolon_initial(std::move(_semicolon_initial))
797 , expression_termination(std::move(_expression_termination))
798 , semicolon_termination(std::move(_semicolon_termination))
799 , expression_increment(std::move(_expression_increment))
800 , paren_r_token(std::move(_paren_r_token))
801 , scope_body(std::move(_scope_body))
802 {
803 add_child(*for_token);
804 add_child(*paren_l_token);
805 add_child(*expression_initial);
806 add_child(*semicolon_initial);
807 add_child(*expression_termination);
808 add_child(*semicolon_termination);
809 add_child(*expression_increment);
810 add_child(*paren_r_token);
811 add_child(*scope_body);
812 }
813 2 StatementFor::StatementFor(
814 Gyoji::owned<Terminal> _for_token,
815 Gyoji::owned<Terminal> _paren_l_token,
816 Gyoji::owned<TypeSpecifier> _type_specifier,
817 Gyoji::owned<Terminal> _identifier_token,
818 Gyoji::owned<Terminal> _assignment_token,
819 Gyoji::owned<Expression> _expression_initial,
820 Gyoji::owned<Terminal> _semicolon_initial,
821 Gyoji::owned<Expression> _expression_termination,
822 Gyoji::owned<Terminal> _semicolon_termination,
823 Gyoji::owned<Expression> _expression_increment,
824 Gyoji::owned<Terminal> _paren_r_token,
825 Gyoji::owned<ScopeBody> _scope_body
826 2 )
827 6 : SyntaxNode(NONTERMINAL_statement_for, this, _for_token->get_source_ref())
828 2 , is_declaration_initializer(true)
829 2 , for_token(std::move(_for_token))
830 2 , paren_l_token(std::move(_paren_l_token))
831 2 , type_specifier(std::move(_type_specifier))
832 2 , identifier_token(std::move(_identifier_token))
833 2 , assignment_token(std::move(_assignment_token))
834 2 , expression_initial(std::move(_expression_initial))
835 2 , semicolon_initial(std::move(_semicolon_initial))
836 2 , expression_termination(std::move(_expression_termination))
837 2 , semicolon_termination(std::move(_semicolon_termination))
838 2 , expression_increment(std::move(_expression_increment))
839 2 , paren_r_token(std::move(_paren_r_token))
840 4 , scope_body(std::move(_scope_body))
841 {
842 2 add_child(*for_token);
843 2 add_child(*paren_l_token);
844 2 add_child(*type_specifier);
845 2 add_child(*identifier_token);
846 2 add_child(*assignment_token);
847 2 add_child(*expression_initial);
848 2 add_child(*semicolon_initial);
849 2 add_child(*expression_termination);
850 2 add_child(*semicolon_termination);
851 2 add_child(*expression_increment);
852 2 add_child(*paren_r_token);
853 2 add_child(*scope_body);
854 2 }
855 2 StatementFor::~StatementFor()
856 2 {}
857 bool
858 2 StatementFor::is_declaration() const
859 2 { return is_declaration_initializer; }
860 const TypeSpecifier &
861 2 StatementFor::get_type_specifier() const
862 2 { return *type_specifier; }
863 const Terminal &
864 4 StatementFor::get_identifier() const
865 4 { return *identifier_token; }
866 const Expression &
867 2 StatementFor::get_expression_initial() const
868 2 { return *expression_initial; }
869 const Expression &
870 2 StatementFor::get_expression_termination() const
871 2 { return *expression_termination; }
872 const Expression &
873 2 StatementFor::get_expression_increment() const
874 2 { return *expression_increment; }
875 const ScopeBody &
876 4 StatementFor::get_scope_body() const
877 4 { return *scope_body; }
878 ///////////////////////////////////////////////////
879 8 StatementSwitchBlock::StatementSwitchBlock(
880 Gyoji::owned<Terminal> _default_token,
881 Gyoji::owned<Terminal> _colon_token,
882 Gyoji::owned<ScopeBody> _scope_body
883 8 )
884 24 : SyntaxNode(NONTERMINAL_statement_switch_block, this, _default_token->get_source_ref())
885 8 , m_is_default(true)
886 8 , default_token(std::move(_default_token))
887 8 , colon_token(std::move(_colon_token))
888 24 , scope_body(std::move(_scope_body))
889 {
890 8 add_child(*default_token);
891 8 add_child(*colon_token);
892 8 add_child(*scope_body);
893 8 }
894 24 StatementSwitchBlock::StatementSwitchBlock(
895 Gyoji::owned<Terminal> _case_token,
896 Gyoji::owned<Expression> _expression,
897 Gyoji::owned<Terminal> _colon_token,
898 Gyoji::owned<ScopeBody> _scope_body
899 24 )
900 72 : SyntaxNode(NONTERMINAL_statement_switch_block, this, _case_token->get_source_ref())
901 24 , m_is_default(false)
902 24 , case_token(std::move(_case_token))
903 24 , expression(std::move(_expression))
904 24 , colon_token(std::move(_colon_token))
905 48 , scope_body(std::move(_scope_body))
906 {
907 24 add_child(*case_token);
908 24 add_child(*expression);
909 24 add_child(*colon_token);
910 24 add_child(*scope_body);
911 24 }
912 32 StatementSwitchBlock::~StatementSwitchBlock()
913 32 {}
914 bool
915 StatementSwitchBlock::is_default() const
916 { return m_is_default; }
917 const Expression &
918 StatementSwitchBlock::get_expression()
919 { return *expression; }
920 const ScopeBody &
921 StatementSwitchBlock::get_scope_body()
922 { return *scope_body; }
923
924 ///////////////////////////////////////////////////
925
926 8 StatementSwitchContent::StatementSwitchContent(const Gyoji::context::SourceReference & _source_ref)
927 8 : SyntaxNode(NONTERMINAL_statement_switch_content, this, _source_ref)
928 8 {}
929 8 StatementSwitchContent::~StatementSwitchContent()
930 8 {}
931 const std::vector<Gyoji::owned<StatementSwitchBlock>> &
932 StatementSwitchContent::get_blocks() const
933 { return blocks; }
934 void
935 32 StatementSwitchContent::add_block(Gyoji::owned<StatementSwitchBlock> _block)
936 {
937 32 add_child(*_block.get());
938 32 blocks.push_back(std::move(_block));
939 32 }
940
941 ///////////////////////////////////////////////////
942 8 StatementSwitch::StatementSwitch(
943 Gyoji::owned<Terminal> _switch_token,
944 Gyoji::owned<Terminal> _paren_l_token,
945 Gyoji::owned<Expression> _expression,
946 Gyoji::owned<Terminal> _paren_r_token,
947 Gyoji::owned<Terminal> _brace_l_token,
948 Gyoji::owned<StatementSwitchContent> _switch_content,
949 Gyoji::owned<Terminal> _brace_r_token
950 8 )
951 24 : SyntaxNode(NONTERMINAL_statement_switch, this, _switch_token->get_source_ref())
952 8 , switch_token(std::move(_switch_token))
953 8 , paren_l_token(std::move(_paren_l_token))
954 8 , expression(std::move(_expression))
955 8 , paren_r_token(std::move(_paren_r_token))
956 8 , brace_l_token(std::move(_brace_l_token))
957 8 , switch_content(std::move(_switch_content))
958 16 , brace_r_token(std::move(_brace_r_token))
959 {
960 8 add_child(*switch_token);
961 8 add_child(*paren_l_token);
962 8 add_child(*expression);
963 8 add_child(*paren_r_token);
964 8 add_child(*brace_l_token);
965 8 add_child(*switch_content);
966 8 add_child(*brace_r_token);
967 8 }
968 8 StatementSwitch::~StatementSwitch()
969 8 {}
970 const Expression &
971 StatementSwitch::get_expression() const
972 { return *expression; }
973 const StatementSwitchContent &
974 StatementSwitch::get_switch_content() const
975 { return *switch_content; }
976 ///////////////////////////////////////////////////
977 10 StatementLabel::StatementLabel(
978 Gyoji::owned<Terminal> _label_token,
979 Gyoji::owned<Terminal> _identifier_token,
980 Gyoji::owned<Terminal> _colon_token
981 10 )
982 30 : SyntaxNode(NONTERMINAL_statement_label, this, _label_token->get_source_ref())
983 10 , label_token(std::move(_label_token))
984 10 , identifier_token(std::move(_identifier_token))
985 20 , colon_token(std::move(_colon_token))
986 {
987 10 add_child(*label_token);
988 10 add_child(*identifier_token);
989 10 add_child(*colon_token);
990 10 }
991 10 StatementLabel::~StatementLabel()
992 10 {}
993 const std::string &
994 2 StatementLabel::get_name() const
995 2 { return identifier_token->get_value(); }
996 const SourceReference &
997 2 StatementLabel::get_name_source_ref() const
998 2 { return identifier_token->get_source_ref(); }
999
1000 ///////////////////////////////////////////////////
1001 10 StatementGoto::StatementGoto(
1002 Gyoji::owned<Terminal> _goto_token,
1003 Gyoji::owned<Terminal> _identifier_token,
1004 Gyoji::owned<Terminal> _semicolon_token
1005 10 )
1006 30 : SyntaxNode(NONTERMINAL_statement_goto, this, _goto_token->get_source_ref())
1007 10 , goto_token(std::move(_goto_token))
1008 10 , identifier_token(std::move(_identifier_token))
1009 20 , semicolon_token(std::move(_semicolon_token))
1010 {
1011 10 add_child(*goto_token);
1012 10 add_child(*identifier_token);
1013 10 add_child(*semicolon_token);
1014 10 }
1015 10 StatementGoto::~StatementGoto()
1016 10 {}
1017 const std::string &
1018 2 StatementGoto::get_label() const
1019 2 { return identifier_token->get_value(); }
1020 const SourceReference &
1021 2 StatementGoto::get_label_source_ref() const
1022 2 { return identifier_token->get_source_ref(); }
1023 ///////////////////////////////////////////////////
1024 10 StatementBreak::StatementBreak(
1025 Gyoji::owned<Terminal> _break_token,
1026 Gyoji::owned<Terminal> _semicolon_token
1027 10 )
1028 30 : SyntaxNode(NONTERMINAL_statement_break, this, _break_token->get_source_ref())
1029 10 , break_token(std::move(_break_token))
1030 20 , semicolon_token(std::move(_semicolon_token))
1031 {
1032 10 add_child(*break_token);
1033 10 add_child(*semicolon_token);
1034 10 }
1035 10 StatementBreak::~StatementBreak()
1036 10 {}
1037 ///////////////////////////////////////////////////
1038 10 StatementContinue::StatementContinue(
1039 Gyoji::owned<Terminal> _continue_token,
1040 Gyoji::owned<Terminal> _semicolon_token
1041 10 )
1042 30 : SyntaxNode(NONTERMINAL_statement_continue, this, _continue_token->get_source_ref())
1043 10 , continue_token(std::move(_continue_token))
1044 20 , semicolon_token(std::move(_semicolon_token))
1045 {
1046 10 add_child(*continue_token);
1047 10 add_child(*semicolon_token);
1048 10 }
1049 10 StatementContinue::~StatementContinue()
1050 10 {}
1051 ///////////////////////////////////////////////////
1052 492 StatementReturn::StatementReturn(
1053 Gyoji::owned<Terminal> _return_token,
1054 Gyoji::owned<Expression> _expression,
1055 Gyoji::owned<Terminal> _semicolon_token
1056 492 )
1057 1476 : SyntaxNode(NONTERMINAL_statement_return, this, _return_token->get_source_ref())
1058 492 , return_token(std::move(_return_token))
1059 492 , void_return(false)
1060 492 , expression(std::move(_expression))
1061 984 , semicolon_token(std::move(_semicolon_token))
1062 {
1063 492 add_child(*return_token);
1064 492 add_child(*expression);
1065 492 add_child(*semicolon_token);
1066 492 }
1067 2 StatementReturn::StatementReturn(
1068 Gyoji::owned<Terminal> _return_token,
1069 Gyoji::owned<Terminal> _semicolon_token
1070 2 )
1071 6 : SyntaxNode(NONTERMINAL_statement_return, this, _return_token->get_source_ref())
1072 2 , return_token(std::move(_return_token))
1073 2 , void_return(true)
1074 2 , expression(nullptr)
1075 4 , semicolon_token(std::move(_semicolon_token))
1076 {
1077 2 add_child(*return_token);
1078 2 add_child(*semicolon_token);
1079 2 }
1080
1081 494 StatementReturn::~StatementReturn()
1082 494 {}
1083
1084 bool
1085 284 StatementReturn::is_void() const
1086 284 { return void_return; }
1087
1088 const Expression &
1089 282 StatementReturn::get_expression() const
1090 282 { return *expression; }
1091 ///////////////////////////////////////////////////
1092 3220 Statement::Statement(StatementType _statement, const SyntaxNode & _sn)
1093 6440 : SyntaxNode(NONTERMINAL_statement, this, _sn.get_source_ref())
1094 3220 , statement(std::move(_statement))
1095 {
1096 3220 add_child(_sn);
1097 3220 }
1098 3220 Statement::~Statement()
1099 3220 {}
1100 const Statement::StatementType &
1101 1090 Statement::get_statement() const
1102 1090 { return statement; }
1103
1104 ///////////////////////////////////////////////////
1105 824 StatementList::StatementList(const Gyoji::context::SourceReference & _source_ref)
1106 824 : SyntaxNode(NONTERMINAL_statement_list, this, _source_ref)
1107 824 {}
1108 824 StatementList::~StatementList()
1109 824 {}
1110 void
1111 3220 StatementList::add_statement(Gyoji::owned<Statement> _statement)
1112 {
1113 3220 add_child(*_statement);
1114 3220 statements.push_back(std::move(_statement));
1115 3220 }
1116 const std::vector<Gyoji::owned<Statement>> &
1117 322 StatementList::get_statements() const
1118 322 { return statements; }
1119
1120 ///////////////////////////////////////////////////
1121 824 ScopeBody::ScopeBody(
1122 Gyoji::owned<Terminal> _brace_l_token,
1123 Gyoji::owned<StatementList> _statement_list,
1124 Gyoji::owned<Terminal> _brace_r_token
1125 824 )
1126 2472 : SyntaxNode(NONTERMINAL_scope_body, this, _brace_l_token->get_source_ref())
1127 824 , brace_l_token(std::move(_brace_l_token))
1128 824 , statement_list(std::move(_statement_list))
1129 1648 , brace_r_token(std::move(_brace_r_token))
1130 {
1131 824 add_child(*brace_l_token);
1132 824 add_child(*statement_list);
1133 824 add_child(*brace_r_token);
1134 824 }
1135 824 ScopeBody::~ScopeBody()
1136 824 {}
1137 const StatementList &
1138 322 ScopeBody::get_statements() const
1139 322 { return *statement_list; }
1140 ///////////////////////////////////////////////////
1141 444 FileStatementFunctionDefinition::FileStatementFunctionDefinition(
1142 Gyoji::owned<FileStatementFunctionDeclStart> _start,
1143 Gyoji::owned<Terminal> _paren_l,
1144 Gyoji::owned<FunctionDefinitionArgList> _arguments,
1145 Gyoji::owned<Terminal> _paren_r,
1146 Gyoji::owned<ScopeBody> _scope_body
1147 444 )
1148 1332 : SyntaxNode(NONTERMINAL_file_statement_function_declaration, this, _start->get_source_ref())
1149 444 , start(std::move(_start))
1150 444 , paren_l(std::move(_paren_l))
1151 444 , arguments(std::move(_arguments))
1152 444 , paren_r(std::move(_paren_r))
1153 888 , scope_body(std::move(_scope_body))
1154 {
1155 444 add_child(*start);
1156 444 add_child(*paren_l);
1157 444 add_child(*arguments);
1158 444 add_child(*paren_r);
1159 444 add_child(*scope_body);
1160 444 }
1161 444 FileStatementFunctionDefinition::~FileStatementFunctionDefinition()
1162 444 {}
1163
1164 const AccessModifier &
1165 FileStatementFunctionDefinition::get_access_modifier() const
1166 { return start->get_access_modifier(); }
1167
1168 const UnsafeModifier &
1169 FileStatementFunctionDefinition::get_unsafe_modifier() const
1170 { return start->get_unsafe_modifier(); }
1171
1172 const TypeSpecifier &
1173 532 FileStatementFunctionDefinition::get_return_type() const
1174 532 { return start->get_type_specifier(); }
1175
1176 const Terminal &
1177 798 FileStatementFunctionDefinition::get_name() const
1178 798 { return start->get_name(); }
1179
1180 const FunctionDefinitionArgList &
1181 532 FileStatementFunctionDefinition::get_arguments() const
1182 532 { return *arguments; }
1183
1184 const ScopeBody &
1185 268 FileStatementFunctionDefinition::get_scope_body() const
1186 268 { return *scope_body; }
1187
1188 ///////////////////////////////////////////////////
1189
1190 ArrayLength::ArrayLength(const Gyoji::context::SourceReference & _source_ref)
1191 : SyntaxNode(NONTERMINAL_array_length, this, _source_ref)
1192 , bracket_l_token(nullptr)
1193 , literal_int_token(nullptr)
1194 , bracket_r_token(nullptr)
1195 {}
1196
1197 ArrayLength::ArrayLength(
1198 Gyoji::owned<Terminal> _bracket_l_token,
1199 Gyoji::owned<Terminal> _literal_int_token,
1200 Gyoji::owned<Terminal> _bracket_r_token
1201 )
1202 : SyntaxNode(NONTERMINAL_array_length, this, _bracket_l_token->get_source_ref())
1203 , bracket_l_token(std::move(_bracket_l_token))
1204 , literal_int_token(std::move(_literal_int_token))
1205 , bracket_r_token(std::move(_bracket_r_token))
1206 {
1207 add_child(*bracket_l_token);
1208 add_child(*literal_int_token);
1209 add_child(*bracket_r_token);
1210 }
1211 ArrayLength::~ArrayLength()
1212 {}
1213 bool
1214 ArrayLength::is_array() const
1215 {
1216 return literal_int_token.get() != nullptr;
1217 }
1218 size_t
1219 ArrayLength::get_size() const
1220 { return (size_t)atol(literal_int_token->get_value().c_str());}
1221 const Gyoji::context::SourceReference &
1222 ArrayLength::get_size_source_ref() const
1223 { return literal_int_token->get_source_ref(); }
1224
1225 ///////////////////////////////////////////////////
1226 184 ClassDeclStart::ClassDeclStart(
1227 Gyoji::owned<AccessModifier> _access_modifier,
1228 Gyoji::owned<Terminal> _class_token,
1229 Gyoji::owned<Terminal> _identifier_token,
1230 Gyoji::owned<ClassArgumentList> _class_argument_list,
1231 bool is_identifier
1232 184 )
1233 552 : SyntaxNode(NONTERMINAL_class_decl_start, this, _access_modifier->get_source_ref())
1234 184 , access_modifier(std::move(_access_modifier))
1235 184 , class_token(std::move(_class_token))
1236 184 , identifier_token(std::move(_identifier_token))
1237 368 , class_argument_list(std::move(_class_argument_list))
1238 {
1239 184 add_child(*access_modifier);
1240 184 add_child(*class_token);
1241 184 add_child(*identifier_token);
1242 184 add_child(*class_argument_list);
1243 184 name = identifier_token->get_fully_qualified_name();
1244 184 }
1245 184 ClassDeclStart::~ClassDeclStart()
1246 184 {}
1247 const AccessModifier &
1248 ClassDeclStart::get_access_modifier() const
1249 { return *access_modifier; }
1250 const std::string &
1251 34 ClassDeclStart::get_name() const
1252 34 { return name; }
1253 const SourceReference &
1254 34 ClassDeclStart::get_name_source_ref() const
1255 34 { return identifier_token->get_source_ref(); }
1256
1257 const ClassArgumentList &
1258 ClassDeclStart::get_argument_list() const
1259 { return *class_argument_list; }
1260 ///////////////////////////////////////////////////
1261 ClassArgumentList::ClassArgumentList(Gyoji::owned<Terminal> _argument)
1262 : SyntaxNode(NONTERMINAL_class_argument_list, this, _argument->get_source_ref())
1263 , paren_l(nullptr)
1264 , paren_r(nullptr)
1265 {
1266 add_child(*_argument);
1267 argument_list.push_back(std::move(_argument));
1268 }
1269 184 ClassArgumentList::ClassArgumentList(const Gyoji::context::SourceReference & _source_ref)
1270 368 : SyntaxNode(NONTERMINAL_class_argument_list, this, _source_ref)
1271 184 , paren_l(nullptr)
1272 184 , paren_r(nullptr)
1273 {
1274 184 }
1275 184 ClassArgumentList::~ClassArgumentList()
1276 184 {}
1277 void
1278 ClassArgumentList::add_parens(Gyoji::owned<Terminal> _paren_l, Gyoji::owned<Terminal> _paren_r)
1279 {
1280 paren_l = std::move(_paren_l);
1281 prepend_child(*paren_l);
1282
1283 paren_r = std::move(_paren_r);
1284 add_child(*paren_r);
1285 }
1286
1287 void
1288 ClassArgumentList::add_argument(Gyoji::owned<Terminal> _comma_token, Gyoji::owned<Terminal> _argument)
1289 {
1290 comma_list.push_back(std::move(_comma_token));
1291 argument_list.push_back(std::move(_argument));
1292 }
1293 const std::vector<Gyoji::owned<Terminal>> &
1294 ClassArgumentList::get_arguments() const
1295 { return argument_list; }
1296 ///////////////////////////////////////////////////
1297 258 ClassMemberDeclarationVariable::ClassMemberDeclarationVariable(
1298 Gyoji::owned<AccessModifier> _access_modifier,
1299 Gyoji::owned<TypeSpecifier> _type_specifier,
1300 Gyoji::owned<Terminal> _identifier_token,
1301 Gyoji::owned<Terminal> _semicolon_token
1302 258 )
1303 774 : SyntaxNode(NONTERMINAL_class_member_declaration_variable, this, _access_modifier->get_source_ref())
1304 258 , access_modifier(std::move(_access_modifier))
1305 258 , type_specifier(std::move(_type_specifier))
1306 258 , identifier_token(std::move(_identifier_token))
1307 516 , semicolon_token(std::move(_semicolon_token))
1308 {
1309 258 add_child(*access_modifier);
1310 258 add_child(*type_specifier);
1311 258 add_child(*identifier_token);
1312 258 add_child(*semicolon_token);
1313 258 }
1314 258 ClassMemberDeclarationVariable::~ClassMemberDeclarationVariable()
1315 258 {}
1316 const AccessModifier &
1317 ClassMemberDeclarationVariable::get_access_modifier() const
1318 { return *access_modifier; }
1319 const TypeSpecifier &
1320 42 ClassMemberDeclarationVariable::get_type_specifier() const
1321 42 { return *type_specifier; }
1322 const std::string &
1323 126 ClassMemberDeclarationVariable::get_name() const
1324 126 { return identifier_token->get_value(); }
1325 const SourceReference &
1326 42 ClassMemberDeclarationVariable::get_name_source_ref() const
1327 42 { return identifier_token->get_source_ref(); }
1328 ///////////////////////////////////////////////////
1329 10 ClassMemberDeclarationMethod::ClassMemberDeclarationMethod(
1330 Gyoji::owned<AccessModifier> _access_modifier,
1331 Gyoji::owned<TypeSpecifier> _type_specifier,
1332 Gyoji::owned<Terminal> _identifier_token,
1333 Gyoji::owned<Terminal> _paren_l_token,
1334 Gyoji::owned<FunctionDefinitionArgList> _function_definition_arg_list,
1335 Gyoji::owned<Terminal> _paren_r_token,
1336 Gyoji::owned<Terminal> _semicolon_token
1337 10 )
1338 30 : SyntaxNode(NONTERMINAL_class_member_declaration_method, this, _access_modifier->get_source_ref())
1339 10 , access_modifier(std::move(_access_modifier))
1340 10 , type_specifier(std::move(_type_specifier))
1341 10 , identifier_token(std::move(_identifier_token))
1342 10 , paren_l_token(std::move(_paren_l_token))
1343 10 , function_definition_arg_list(std::move(_function_definition_arg_list))
1344 10 , paren_r_token(std::move(_paren_r_token))
1345 20 , semicolon_token(std::move(_semicolon_token))
1346 {
1347 10 add_child(*access_modifier);
1348 10 add_child(*type_specifier);
1349 10 add_child(*identifier_token);
1350 10 add_child(*paren_l_token);
1351 10 add_child(*function_definition_arg_list);
1352 10 add_child(*paren_r_token);
1353 10 add_child(*semicolon_token);
1354 10 }
1355 10 ClassMemberDeclarationMethod::~ClassMemberDeclarationMethod()
1356 10 {}
1357 const AccessModifier &
1358 ClassMemberDeclarationMethod::get_access_modifier() const
1359 { return *access_modifier; }
1360 const TypeSpecifier &
1361 2 ClassMemberDeclarationMethod::get_type_specifier() const
1362 2 { return *type_specifier; }
1363 const Terminal &
1364 6 ClassMemberDeclarationMethod::get_identifier() const
1365 6 { return *identifier_token; }
1366 const FunctionDefinitionArgList &
1367 2 ClassMemberDeclarationMethod::get_arguments() const
1368 2 { return *function_definition_arg_list; }
1369 ///////////////////////////////////////////////////
1370 8 ClassMemberDeclarationConstructor::ClassMemberDeclarationConstructor(
1371 Gyoji::owned<AccessModifier> _access_modifier,
1372 Gyoji::owned<TypeSpecifier> _type_specifier,
1373 Gyoji::owned<Terminal> _paren_l_token,
1374 Gyoji::owned<FunctionDefinitionArgList> _function_definition_arg_list,
1375 Gyoji::owned<Terminal> _paren_r_token,
1376 Gyoji::owned<Terminal> _semicolon_token
1377 8 )
1378 24 : SyntaxNode(NONTERMINAL_class_member_declaration_method, this, _access_modifier->get_source_ref())
1379 8 , access_modifier(std::move(_access_modifier))
1380 8 , type_specifier(std::move(_type_specifier))
1381 8 , paren_l_token(std::move(_paren_l_token))
1382 8 , function_definition_arg_list(std::move(_function_definition_arg_list))
1383 8 , paren_r_token(std::move(_paren_r_token))
1384 16 , semicolon_token(std::move(_semicolon_token))
1385 {
1386 8 add_child(*access_modifier);
1387 8 add_child(*type_specifier);
1388 8 add_child(*paren_l_token);
1389 8 add_child(*function_definition_arg_list);
1390 8 add_child(*paren_r_token);
1391 8 add_child(*semicolon_token);
1392 8 }
1393 8 ClassMemberDeclarationConstructor::~ClassMemberDeclarationConstructor()
1394 8 {}
1395 const AccessModifier &
1396 ClassMemberDeclarationConstructor::get_access_modifier() const
1397 { return *access_modifier; }
1398 const TypeSpecifier &
1399 ClassMemberDeclarationConstructor::get_type_specifier() const
1400 { return *type_specifier; }
1401 const FunctionDefinitionArgList &
1402 ClassMemberDeclarationConstructor::get_arguments() const
1403 { return *function_definition_arg_list; }
1404 ///////////////////////////////////////////////////
1405 8 ClassMemberDeclarationDestructor::ClassMemberDeclarationDestructor(
1406 Gyoji::owned<AccessModifier> _access_modifier,
1407 Gyoji::owned<Terminal> _tilde_token,
1408 Gyoji::owned<TypeSpecifier> _type_specifier,
1409 Gyoji::owned<Terminal> _paren_l_token,
1410 Gyoji::owned<FunctionDefinitionArgList> _function_definition_arg_list,
1411 Gyoji::owned<Terminal> _paren_r_token,
1412 Gyoji::owned<Terminal> _semicolon_token
1413 8 )
1414 24 : SyntaxNode(NONTERMINAL_class_member_declaration_method, this, _access_modifier->get_source_ref())
1415 8 , access_modifier(std::move(_access_modifier))
1416 8 , tilde_token(std::move(_tilde_token))
1417 8 , type_specifier(std::move(_type_specifier))
1418 8 , paren_l_token(std::move(_paren_l_token))
1419 8 , function_definition_arg_list(std::move(_function_definition_arg_list))
1420 8 , paren_r_token(std::move(_paren_r_token))
1421 16 , semicolon_token(std::move(_semicolon_token))
1422 {
1423 8 add_child(*access_modifier);
1424 8 add_child(*tilde_token);
1425 8 add_child(*type_specifier);
1426 8 add_child(*paren_l_token);
1427 8 add_child(*function_definition_arg_list);
1428 8 add_child(*paren_r_token);
1429 8 add_child(*semicolon_token);
1430 8 }
1431 8 ClassMemberDeclarationDestructor::~ClassMemberDeclarationDestructor()
1432 8 {}
1433 const AccessModifier &
1434 ClassMemberDeclarationDestructor::get_access_modifier() const
1435 { return *access_modifier; }
1436 const TypeSpecifier &
1437 ClassMemberDeclarationDestructor::get_type_specifier() const
1438 { return *type_specifier; }
1439 const FunctionDefinitionArgList &
1440 ClassMemberDeclarationDestructor::get_arguments() const
1441 { return *function_definition_arg_list; }
1442 ///////////////////////////////////////////////////
1443 316 ClassMemberDeclaration::ClassMemberDeclaration(
1444 MemberType _member,
1445 const SyntaxNode & _sn
1446 316 )
1447 632 : SyntaxNode(NONTERMINAL_class_member_declaration, this, _sn.get_source_ref())
1448 316 , member(std::move(_member))
1449 {
1450 316 add_child(_sn);
1451 316 }
1452 316 ClassMemberDeclaration::~ClassMemberDeclaration()
1453 316 {}
1454 const ClassMemberDeclaration::MemberType &
1455 44 ClassMemberDeclaration::get_member()
1456 44 { return member; }
1457 ///////////////////////////////////////////////////
1458
1459
1460 128 ClassMemberDeclarationList::ClassMemberDeclarationList(const Gyoji::context::SourceReference & _source_ref)
1461 128 : SyntaxNode(NONTERMINAL_class_member_declaration_list, this, _source_ref)
1462 128 {}
1463 128 ClassMemberDeclarationList::~ClassMemberDeclarationList()
1464 128 {}
1465 const std::vector<Gyoji::owned<ClassMemberDeclaration>> &
1466 16 ClassMemberDeclarationList::get_members() const
1467 {
1468 16 return members;
1469 }
1470 void
1471 316 ClassMemberDeclarationList::add_member(Gyoji::owned<ClassMemberDeclaration> _member)
1472 {
1473 316 add_child(*_member);
1474 316 members.push_back(std::move(_member));
1475 316 }
1476 ///////////////////////////////////////////////////
1477 56 ClassDeclaration::ClassDeclaration(
1478 Gyoji::owned<ClassDeclStart> _class_decl_start,
1479 Gyoji::owned<Terminal> _semicolon_token
1480 56 )
1481 168 : SyntaxNode(NONTERMINAL_class_declaration, this, _class_decl_start->get_source_ref())
1482 56 , class_decl_start(std::move(_class_decl_start))
1483 112 , semicolon_token(std::move(_semicolon_token))
1484 {
1485 56 add_child(*class_decl_start);
1486 56 add_child(*semicolon_token);
1487 56 }
1488 56 ClassDeclaration::~ClassDeclaration()
1489 56 {}
1490 const AccessModifier &
1491 ClassDeclaration::get_access_modifier() const
1492 {
1493 return class_decl_start->get_access_modifier();
1494 }
1495 const std::string &
1496 8 ClassDeclaration::get_name() const
1497 {
1498 8 return class_decl_start->get_name();
1499 }
1500 const SourceReference &
1501 8 ClassDeclaration::get_name_source_ref() const
1502 8 { return class_decl_start->get_name_source_ref(); }
1503
1504 const ClassArgumentList &
1505 ClassDeclaration::get_argument_list() const
1506 {
1507 return class_decl_start->get_argument_list();
1508 }
1509
1510 ///////////////////////////////////////////////////
1511 128 ClassDefinition::ClassDefinition(
1512 Gyoji::owned<ClassDeclStart> _class_decl_start,
1513 Gyoji::owned<Terminal> _brace_l_token,
1514 Gyoji::owned<ClassMemberDeclarationList> _class_member_declaration_list,
1515 Gyoji::owned<Terminal> _brace_r_token,
1516 Gyoji::owned<Terminal> _semicolon_token
1517 128 )
1518 384 : SyntaxNode(NONTERMINAL_class_definition, this, _class_decl_start->get_source_ref())
1519 128 , class_decl_start(std::move(_class_decl_start))
1520 128 , brace_l_token(std::move(_brace_l_token))
1521 128 , class_member_declaration_list(std::move(_class_member_declaration_list))
1522 128 , brace_r_token(std::move(_brace_r_token))
1523 256 , semicolon_token(std::move(_semicolon_token))
1524 {
1525 128 add_child(*class_decl_start);
1526 128 add_child(*brace_l_token);
1527 128 add_child(*class_member_declaration_list);
1528 128 add_child(*brace_r_token);
1529 128 add_child(*semicolon_token);
1530 128 }
1531 128 ClassDefinition::~ClassDefinition()
1532 128 {}
1533 const AccessModifier &
1534 ClassDefinition::get_access_modifier() const
1535 {
1536 return class_decl_start->get_access_modifier();
1537 }
1538 const std::string &
1539 26 ClassDefinition::get_name() const
1540 {
1541 26 return class_decl_start->get_name();
1542 }
1543 const SourceReference &
1544 26 ClassDefinition::get_name_source_ref() const
1545 26 { return class_decl_start->get_name_source_ref(); }
1546 const ClassArgumentList &
1547 ClassDefinition::get_argument_list() const
1548 {
1549 return class_decl_start->get_argument_list();
1550 }
1551 const std::vector<Gyoji::owned<ClassMemberDeclaration>> &
1552 16 ClassDefinition::get_members() const
1553 16 { return class_member_declaration_list->get_members(); }
1554
1555 ///////////////////////////////////////////////////
1556 146 TypeDefinition::TypeDefinition(
1557 Gyoji::owned<AccessModifier> _access_modifier,
1558 Gyoji::owned<Terminal> _typedef_token,
1559 Gyoji::owned<TypeSpecifier> _type_specifier,
1560 Gyoji::owned<Terminal> _identifier_token,
1561 Gyoji::owned<Terminal> _semicolon_token
1562 146 )
1563 438 : SyntaxNode(NONTERMINAL_type_definition, this, _access_modifier->get_source_ref())
1564 146 , access_modifier(std::move(_access_modifier))
1565 146 , typedef_token(std::move(_typedef_token))
1566 146 , type_specifier(std::move(_type_specifier))
1567 146 , identifier_token(std::move(_identifier_token))
1568 292 , semicolon_token(std::move(_semicolon_token))
1569 {
1570 146 add_child(*access_modifier);
1571 146 add_child(*typedef_token);
1572 146 add_child(*type_specifier);
1573 146 add_child(*identifier_token);
1574 146 add_child(*semicolon_token);
1575 146 }
1576 146 TypeDefinition::~TypeDefinition()
1577 146 {}
1578 const AccessModifier &
1579 8 TypeDefinition::get_access_modifier() const
1580 8 { return *access_modifier; }
1581 const std::string &
1582 20 TypeDefinition::get_name() const
1583 20 { return identifier_token->get_value(); }
1584 const SourceReference &
1585 TypeDefinition::get_name_source_ref() const
1586 { return identifier_token->get_source_ref(); }
1587 const TypeSpecifier &
1588 12 TypeDefinition::get_type_specifier() const
1589 12 { return *type_specifier; }
1590
1591 ///////////////////////////////////////////////////
1592 68 EnumDefinitionValue::EnumDefinitionValue(
1593 Gyoji::owned<Terminal> _identifier_token,
1594 Gyoji::owned<Terminal> _equals_token,
1595 Gyoji::owned<Expression> _expression_primary,
1596 Gyoji::owned<Terminal> _semicolon_token
1597 68 )
1598 204 : SyntaxNode(NONTERMINAL_enum_definition_value, this, _identifier_token->get_source_ref())
1599 68 , identifier_token(std::move(_identifier_token))
1600 68 , equals_token(std::move(_equals_token))
1601 68 , expression_primary(std::move(_expression_primary))
1602 136 , semicolon_token(std::move(_semicolon_token))
1603 {
1604 68 add_child(*identifier_token);
1605 68 add_child(*equals_token);
1606 68 add_child(*expression_primary);
1607 68 add_child(*semicolon_token);
1608 68 }
1609 68 EnumDefinitionValue::~EnumDefinitionValue()
1610 68 {}
1611 const std::string &
1612 EnumDefinitionValue::get_name() const
1613 { return identifier_token->get_value(); }
1614 const SourceReference &
1615 EnumDefinitionValue::get_name_source_ref() const
1616 { return identifier_token->get_source_ref(); }
1617
1618 const Expression &
1619 EnumDefinitionValue::get_expression() const
1620 { return *expression_primary; }
1621
1622 ///////////////////////////////////////////////////
1623 26 EnumDefinitionValueList::EnumDefinitionValueList(const Gyoji::context::SourceReference & _source_ref)
1624 26 : SyntaxNode(NONTERMINAL_enum_definition_value_list, this, _source_ref)
1625 26 {}
1626
1627 26 EnumDefinitionValueList::~EnumDefinitionValueList()
1628 26 {}
1629 void
1630 68 EnumDefinitionValueList::add_value(Gyoji::owned<EnumDefinitionValue> _value)
1631 {
1632 68 add_child(*_value);
1633 68 values.push_back(std::move(_value));
1634 68 }
1635 const std::vector<Gyoji::owned<EnumDefinitionValue>> &
1636 EnumDefinitionValueList::get_values() const
1637 { return values; }
1638
1639 ///////////////////////////////////////////////////
1640 26 EnumDefinition::EnumDefinition(
1641 Gyoji::owned<AccessModifier> _access_modifier,
1642 Gyoji::owned<Terminal> _enum_token,
1643 Gyoji::owned<Terminal> _type_name_token,
1644 Gyoji::owned<Terminal> _identifier_token,
1645 Gyoji::owned<Terminal> _brace_l_token,
1646 Gyoji::owned<EnumDefinitionValueList> _enum_value_list,
1647 Gyoji::owned<Terminal> _brace_r_token,
1648 Gyoji::owned<Terminal> _semicolon_token
1649 26 )
1650 78 : SyntaxNode(NONTERMINAL_enum_definition, this, _access_modifier->get_source_ref())
1651 26 , access_modifier(std::move(_access_modifier))
1652 26 , enum_token(std::move(_enum_token))
1653 26 , type_name_token(std::move(_type_name_token))
1654 26 , identifier_token(std::move(_identifier_token))
1655 26 , brace_l_token(std::move(_brace_l_token))
1656 26 , enum_value_list(std::move(_enum_value_list))
1657 26 , brace_r_token(std::move(_brace_r_token))
1658 52 , semicolon_token(std::move(_semicolon_token))
1659 {
1660 26 add_child(*access_modifier);
1661 26 add_child(*enum_token);
1662 26 add_child(*type_name_token);
1663 26 add_child(*identifier_token);
1664 26 add_child(*brace_l_token);
1665 26 add_child(*enum_value_list);
1666 26 add_child(*brace_r_token);
1667 26 add_child(*semicolon_token);
1668 26 }
1669 26 EnumDefinition::~EnumDefinition()
1670 26 {}
1671 const AccessModifier &
1672 EnumDefinition::get_access_modifier() const
1673 { return *access_modifier; }
1674 const std::string &
1675 EnumDefinition::get_type_name() const
1676 { return type_name_token->get_value(); }
1677 const SourceReference &
1678 EnumDefinition::get_type_name_source_ref() const
1679 { return type_name_token->get_source_ref(); }
1680 const std::string &
1681 EnumDefinition::get_name() const
1682 { return identifier_token->get_value(); }
1683 const SourceReference &
1684 EnumDefinition::get_name_source_ref() const
1685 { return identifier_token->get_source_ref(); }
1686 const EnumDefinitionValueList &
1687 EnumDefinition::get_value_list() const
1688 { return *enum_value_list; }
1689 ///////////////////////////////////////////////////
1690 3168 ExpressionPrimaryIdentifier::ExpressionPrimaryIdentifier(Gyoji::owned<Terminal> _identifier_token)
1691 9504 : SyntaxNode(NONTERMINAL_expression_primary_identifier, this, _identifier_token->get_source_ref())
1692 3168 , identifier_token(std::move(_identifier_token))
1693 {
1694 3168 add_child(*identifier_token);
1695 3168 }
1696 3168 ExpressionPrimaryIdentifier::~ExpressionPrimaryIdentifier()
1697 3168 {}
1698 const Terminal &
1699 6276 ExpressionPrimaryIdentifier::get_identifier() const
1700 6276 { return *identifier_token; }
1701 ///////////////////////////////////////////////////
1702 76 ExpressionPrimaryNested::ExpressionPrimaryNested(
1703 Gyoji::owned<Terminal> _paren_l_token,
1704 Gyoji::owned<Expression> _expression,
1705 Gyoji::owned<Terminal> _paren_r_token
1706 76 )
1707 228 : SyntaxNode(NONTERMINAL_expression_primary_nested, this, _paren_l_token->get_source_ref())
1708 76 , paren_l_token(std::move(_paren_l_token))
1709 76 , expression(std::move(_expression))
1710 152 , paren_r_token(std::move(_paren_r_token))
1711 {
1712 76 add_child(*paren_l_token);
1713 76 add_child(*expression);
1714 76 add_child(*paren_r_token);
1715 76 }
1716 76 ExpressionPrimaryNested::~ExpressionPrimaryNested()
1717 76 {}
1718 const Expression &
1719 4 ExpressionPrimaryNested::get_expression() const
1720 4 { return *expression; }
1721
1722 ///////////////////////////////////////////////////
1723 1110 ExpressionPrimaryLiteralInt::ExpressionPrimaryLiteralInt(
1724 Gyoji::owned<Terminal> _literal_token
1725 1110 )
1726 3330 : SyntaxNode(NONTERMINAL_expression_primary_literal_int, this, _literal_token->get_source_ref())
1727 1110 , literal_token(std::move(_literal_token))
1728 {
1729 1110 add_child(*literal_token);
1730 1110 }
1731
1732 1110 ExpressionPrimaryLiteralInt::~ExpressionPrimaryLiteralInt()
1733 1110 {}
1734 const std::string &
1735 ExpressionPrimaryLiteralInt::get_value() const
1736 { return literal_token->get_value(); }
1737
1738 const Terminal &
1739 220 ExpressionPrimaryLiteralInt::get_literal_int_token() const
1740 220 { return *literal_token; }
1741
1742 const SourceReference &
1743 ExpressionPrimaryLiteralInt::get_value_source_ref() const
1744 { return literal_token->get_source_ref(); }
1745 ///////////////////////////////////////////////////
1746 168 ExpressionPrimaryLiteralChar::ExpressionPrimaryLiteralChar(
1747 Gyoji::owned<Terminal> _literal_token
1748 168 )
1749 504 : SyntaxNode(NONTERMINAL_expression_primary_literal_char, this, _literal_token->get_source_ref())
1750 168 , literal_token(std::move(_literal_token))
1751 {
1752 168 add_child(*literal_token);
1753 168 }
1754 168 ExpressionPrimaryLiteralChar::~ExpressionPrimaryLiteralChar()
1755 168 {}
1756 std::string
1757 8 ExpressionPrimaryLiteralChar::get_value() const
1758 {
1759 // Remove the leading and trailing single quote (')
1760 // before passing it down to the semantics
1761 // layer.
1762 8 const std::string & token_value = literal_token->get_value();
1763 8 size_t size = token_value.size();
1764 8 return token_value.substr(1, size-2);
1765 }
1766 const SourceReference &
1767 ExpressionPrimaryLiteralChar::get_value_source_ref() const
1768 { return literal_token->get_source_ref(); }
1769 ///////////////////////////////////////////////////
1770 122 ExpressionPrimaryLiteralString::ExpressionPrimaryLiteralString(
1771 Gyoji::owned<Terminal> _literal_token
1772 122 )
1773 366 : SyntaxNode(NONTERMINAL_expression_primary_literal_string, this, _literal_token->get_source_ref())
1774 122 , literal_token(std::move(_literal_token))
1775 {
1776 122 add_child(*literal_token);
1777 122 }
1778 122 ExpressionPrimaryLiteralString::~ExpressionPrimaryLiteralString()
1779 122 {}
1780 // Instead of just returning a reference, we will
1781 // concatenate the strings together and return the
1782 // resulting string literal still escaped as it was
1783 // in the source file. The unescape of the string
1784 // is delegated to the FunctionResolver because it
1785 // is in a position to return errors whereas this
1786 // class is mainly intended to be just a fairly
1787 // transparent data container with no "real" logic.
1788 std::string
1789 10 ExpressionPrimaryLiteralString::get_value() const
1790 {
1791 10 std::string retstring;
1792 // Strip the leading and trailing " from the string
1793 10 const std::string & token_value = literal_token->get_value();
1794 10 size_t size = token_value.size();
1795 10 std::string firstpart = token_value.substr(1, size-2);
1796
1797 10 retstring = firstpart;
1798
1799 // Do the same thing with the remaining
1800 // strings and append them to the literal.
1801
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 10 times.
12 for (const auto & next_token : additional_strings) {
1802 2 const std::string & next_token_value = next_token->get_value();
1803 2 size = next_token_value.size();
1804 2 std::string nextpart = next_token_value.substr(1, size-2);
1805 2 retstring += nextpart;
1806 2 }
1807
1808 10 return retstring;
1809 10 }
1810 const SourceReference &
1811 ExpressionPrimaryLiteralString::get_value_source_ref() const
1812 { return literal_token->get_source_ref(); }
1813 void
1814 10 ExpressionPrimaryLiteralString::add_string(Gyoji::owned<Terminal> _added)
1815 {
1816 10 add_child(*_added);
1817 10 additional_strings.push_back(std::move(_added));
1818 10 }
1819 ///////////////////////////////////////////////////
1820
1821 static std::string f32_type("f32");
1822 static std::string f64_type("f64");
1823
1824 78 ExpressionPrimaryLiteralFloat::ExpressionPrimaryLiteralFloat(
1825 Gyoji::owned<Terminal> _literal_token
1826 78 )
1827 234 : SyntaxNode(NONTERMINAL_expression_primary_literal_float, this, _literal_token->get_source_ref())
1828 78 , literal_token(std::move(_literal_token))
1829 {
1830 78 add_child(*literal_token);
1831
1832 78 const std::string & token_value = literal_token->get_value();
1833 78 size_t len = token_value.size();
1834
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 76 times.
78 if (Gyoji::misc::endswith(token_value, f32_type)) {
1835 2 float_part = token_value.substr(0, len - f32_type.size());
1836 2 type_part = f32_type;
1837 }
1838
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 74 times.
76 else if (Gyoji::misc::endswith(token_value, f64_type)) {
1839 2 float_part = token_value.substr(0, len - f64_type.size());
1840 2 type_part = f64_type;
1841 }
1842 else {
1843 // We make the default a 'double'
1844 // because in this day and age, there's
1845 // no good reason to default to a 'float'.
1846 74 float_part = token_value;
1847 74 type_part = f64_type;
1848 }
1849 78 }
1850 78 ExpressionPrimaryLiteralFloat::~ExpressionPrimaryLiteralFloat()
1851 78 {}
1852 const std::string &
1853 12 ExpressionPrimaryLiteralFloat::get_value() const
1854 12 { return float_part; }
1855 const std::string &
1856 6 ExpressionPrimaryLiteralFloat::get_type() const
1857 6 { return type_part; }
1858 const SourceReference &
1859 ExpressionPrimaryLiteralFloat::get_value_source_ref() const
1860 { return literal_token->get_source_ref(); }
1861
1862 ///////////////////////////////////////////////////
1863 ExpressionPrimaryLiteralBool::ExpressionPrimaryLiteralBool(
1864 Gyoji::owned<Terminal> _literal_token
1865 )
1866 : SyntaxNode(NONTERMINAL_expression_primary_literal_bool, this, _literal_token->get_source_ref())
1867 , literal_token(std::move(_literal_token))
1868 {
1869 add_child(*literal_token);
1870 value = (literal_token->get_value() == std::string("true"));
1871 }
1872 ExpressionPrimaryLiteralBool::~ExpressionPrimaryLiteralBool()
1873 {}
1874 bool
1875 ExpressionPrimaryLiteralBool::get_value() const
1876 { return value; }
1877 ///////////////////////////////////////////////////
1878
1879 ExpressionPrimaryLiteralNull::ExpressionPrimaryLiteralNull(
1880 Gyoji::owned<Terminal> _literal_token
1881 )
1882 : SyntaxNode(NONTERMINAL_expression_primary_literal_null, this, _literal_token->get_source_ref())
1883 , literal_token(std::move(_literal_token))
1884 {
1885 add_child(*literal_token);
1886 }
1887 ExpressionPrimaryLiteralNull::~ExpressionPrimaryLiteralNull()
1888 {}
1889
1890 ///////////////////////////////////////////////////
1891 58 ExpressionPostfixArrayIndex::ExpressionPostfixArrayIndex(
1892 Gyoji::owned<Expression> _array_expression,
1893 Gyoji::owned<Terminal> _bracket_l_token,
1894 Gyoji::owned<Expression> _index_expression,
1895 Gyoji::owned<Terminal> _bracket_r_token
1896 58 )
1897 174 : SyntaxNode(NONTERMINAL_expression_postfix_array_index, this, _array_expression->get_source_ref())
1898 58 , array_expression(std::move(_array_expression))
1899 58 , bracket_l_token(std::move(_bracket_l_token))
1900 58 , index_expression(std::move(_index_expression))
1901 116 , bracket_r_token(std::move(_bracket_r_token))
1902 {
1903 58 add_child(*array_expression);
1904 58 add_child(*bracket_l_token);
1905 58 add_child(*index_expression);
1906 58 add_child(*bracket_r_token);
1907 58 }
1908 58 ExpressionPostfixArrayIndex::~ExpressionPostfixArrayIndex()
1909 58 {}
1910 const Expression &
1911 10 ExpressionPostfixArrayIndex::get_array() const
1912 10 { return *array_expression; }
1913 const Expression &
1914 10 ExpressionPostfixArrayIndex::get_index() const
1915 10 { return *index_expression; }
1916 ///////////////////////////////////////////////////
1917 450 ArgumentExpressionList::ArgumentExpressionList(const Gyoji::context::SourceReference & _source_ref)
1918 450 : SyntaxNode(NONTERMINAL_argument_expression_list, this, _source_ref)
1919 450 {}
1920 450 ArgumentExpressionList::~ArgumentExpressionList()
1921 450 {}
1922 const std::vector<Gyoji::owned<Expression>> &
1923 66 ArgumentExpressionList::get_arguments() const
1924 66 { return arguments; }
1925 void
1926 184 ArgumentExpressionList::add_argument(Gyoji::owned<Expression> _argument)
1927 {
1928 184 add_child(*_argument);
1929 184 arguments.push_back(std::move(_argument));
1930 184 }
1931 void
1932 76 ArgumentExpressionList::add_argument(Gyoji::owned<Terminal> _comma_token, Gyoji::owned<Expression> _argument)
1933 {
1934 76 add_child(*_comma_token);
1935 76 add_child(*_argument);
1936 76 comma_list.push_back(std::move(_comma_token));
1937 76 arguments.push_back(std::move(_argument));
1938 76 }
1939
1940 ///////////////////////////////////////////////////
1941 450 ExpressionPostfixFunctionCall::ExpressionPostfixFunctionCall(
1942 Gyoji::owned<Expression> _function_expression,
1943 Gyoji::owned<Terminal> _paren_l_token,
1944 Gyoji::owned<ArgumentExpressionList> _arguments,
1945 Gyoji::owned<Terminal> _paren_r_token
1946 450 )
1947 1350 : SyntaxNode(NONTERMINAL_expression_postfix_function_call, this, _function_expression->get_source_ref())
1948 450 , function_expression(std::move(_function_expression))
1949 450 , paren_l_token(std::move(_paren_l_token))
1950 450 , arguments(std::move(_arguments))
1951 900 , paren_r_token(std::move(_paren_r_token))
1952 {
1953 450 add_child(*function_expression);
1954 450 add_child(*paren_l_token);
1955 450 add_child(*arguments);
1956 450 add_child(*paren_r_token);
1957 450 }
1958 450 ExpressionPostfixFunctionCall::~ExpressionPostfixFunctionCall()
1959 450 {}
1960 const Expression &
1961 66 ExpressionPostfixFunctionCall::get_function() const
1962 66 { return *function_expression; }
1963 const ArgumentExpressionList &
1964 66 ExpressionPostfixFunctionCall::get_arguments() const
1965 66 { return *arguments; }
1966 ///////////////////////////////////////////////////
1967 66 ExpressionPostfixDot::ExpressionPostfixDot(
1968 Gyoji::owned<Expression> _expression,
1969 Gyoji::owned<Terminal> _dot_token,
1970 Gyoji::owned<Terminal> _identifier_token
1971 66 )
1972 198 : SyntaxNode(NONTERMINAL_expression_postfix_dot, this, _expression->get_source_ref())
1973 66 , expression(std::move(_expression))
1974 66 , dot_token(std::move(_dot_token))
1975 132 , identifier_token(std::move(_identifier_token))
1976 {
1977 66 add_child(*expression);
1978 66 add_child(*dot_token);
1979 66 add_child(*identifier_token);
1980 66 }
1981 66 ExpressionPostfixDot::~ExpressionPostfixDot()
1982 66 {}
1983 const Expression &
1984 10 ExpressionPostfixDot::get_expression() const
1985 10 { return *expression; }
1986 const Terminal &
1987 10 ExpressionPostfixDot::get_identifier() const
1988 10 { return *identifier_token; }
1989
1990 ///////////////////////////////////////////////////
1991 50 ExpressionPostfixArrow::ExpressionPostfixArrow(
1992 Gyoji::owned<Expression> _expression,
1993 Gyoji::owned<Terminal> _arrow_token,
1994 Gyoji::owned<Terminal> _identifier_token
1995 50 )
1996 150 : SyntaxNode(NONTERMINAL_expression_postfix_arrow, this, _expression->get_source_ref())
1997 50 , expression(std::move(_expression))
1998 50 , arrow_token(std::move(_arrow_token))
1999 100 , identifier_token(std::move(_identifier_token))
2000 {
2001 50 add_child(*expression);
2002 50 add_child(*arrow_token);
2003 50 add_child(*identifier_token);
2004 50 }
2005 50 ExpressionPostfixArrow::~ExpressionPostfixArrow()
2006 50 {}
2007 const Expression &
2008 2 ExpressionPostfixArrow::get_expression() const
2009 2 { return *expression; }
2010 const Terminal &
2011 2 ExpressionPostfixArrow::get_identifier() const
2012 2 { return *identifier_token; }
2013
2014 ///////////////////////////////////////////////////
2015 282 ExpressionPostfixIncDec::ExpressionPostfixIncDec(
2016 Gyoji::owned<Expression> _expression,
2017 Gyoji::owned<Terminal> _operator_token,
2018 OperationType _type
2019 282 )
2020 846 : SyntaxNode(NONTERMINAL_expression_postfix_incdec, this, _expression->get_source_ref())
2021 282 , type(_type)
2022 282 , operator_token(std::move(_operator_token))
2023 564 , expression(std::move(_expression))
2024 {
2025 282 add_child(*expression);
2026 282 add_child(*operator_token);
2027 282 }
2028 282 ExpressionPostfixIncDec::~ExpressionPostfixIncDec()
2029 282 {}
2030 const ExpressionPostfixIncDec::OperationType &
2031 2 ExpressionPostfixIncDec::get_type() const
2032 2 { return type; }
2033 const Expression &
2034 2 ExpressionPostfixIncDec::get_expression() const
2035 2 { return *expression; }
2036 ///////////////////////////////////////////////////
2037 278 ExpressionUnaryPrefix::ExpressionUnaryPrefix(
2038 Gyoji::owned<Terminal> _operator_token,
2039 Gyoji::owned<Expression> _expression,
2040 OperationType _type
2041 278 )
2042 834 : SyntaxNode(NONTERMINAL_expression_unary_prefix, this, _operator_token->get_source_ref())
2043 278 , type(_type)
2044 278 , operator_token(std::move(_operator_token))
2045 556 , expression(std::move(_expression))
2046 {
2047 278 add_child(*operator_token);
2048 278 add_child(*expression);
2049 278 }
2050 278 ExpressionUnaryPrefix::~ExpressionUnaryPrefix()
2051 278 {}
2052 const ExpressionUnaryPrefix::OperationType &
2053 20 ExpressionUnaryPrefix::get_type() const
2054 20 { return type; }
2055 const Gyoji::context::SourceReference &
2056 ExpressionUnaryPrefix::get_operator_source_ref() const
2057 { return operator_token->get_source_ref(); }
2058 const Expression &
2059 20 ExpressionUnaryPrefix::get_expression() const
2060 20 { return *expression; }
2061 ///////////////////////////////////////////////////
2062 72 ExpressionUnarySizeofType::ExpressionUnarySizeofType(
2063 Gyoji::owned<Terminal> _sizeof_token,
2064 Gyoji::owned<Terminal> _paren_l_token,
2065 Gyoji::owned<TypeSpecifier> _type_specifier,
2066 Gyoji::owned<Terminal> _paren_r_token
2067 72 )
2068 216 : SyntaxNode(NONTERMINAL_expression_unary_sizeof_type, this, _sizeof_token->get_source_ref())
2069 72 , sizeof_token(std::move(_sizeof_token))
2070 72 , paren_l_token(std::move(_paren_l_token))
2071 72 , type_specifier(std::move(_type_specifier))
2072 144 , paren_r_token(std::move(_paren_r_token))
2073 {
2074 72 add_child(*sizeof_token);
2075 72 add_child(*paren_l_token);
2076 72 add_child(*type_specifier);
2077 72 add_child(*paren_r_token);
2078 72 }
2079 72 ExpressionUnarySizeofType::~ExpressionUnarySizeofType()
2080 72 {}
2081 const TypeSpecifier &
2082 8 ExpressionUnarySizeofType::get_type_specifier() const
2083 8 { return *type_specifier; }
2084 ///////////////////////////////////////////////////
2085 104 ExpressionCast::ExpressionCast(
2086 Gyoji::owned<Terminal> _cast_token,
2087 Gyoji::owned<Terminal> _paren_l_token,
2088 Gyoji::owned<TypeSpecifier> _type_specifier,
2089 Gyoji::owned<Terminal> _comma_token,
2090 Gyoji::owned<Expression> _expression,
2091 Gyoji::owned<Terminal> _paren_r_token
2092 104 )
2093 312 : SyntaxNode(NONTERMINAL_expression_cast, this, _cast_token->get_source_ref())
2094 104 , cast_token(std::move(_cast_token))
2095 104 , paren_l_token(std::move(_paren_l_token))
2096 104 , type_specifier(std::move(_type_specifier))
2097 104 , comma_token(std::move(_comma_token))
2098 104 , expression(std::move(_expression))
2099 208 , paren_r_token(std::move(_paren_r_token))
2100 {
2101 104 add_child(*cast_token);
2102 104 add_child(*paren_l_token);
2103 104 add_child(*type_specifier);
2104 104 add_child(*comma_token);
2105 104 add_child(*expression);
2106 104 add_child(*paren_r_token);
2107 104 }
2108 104 ExpressionCast::~ExpressionCast()
2109 104 {}
2110 const TypeSpecifier &
2111 ExpressionCast::get_type() const
2112 { return *type_specifier; }
2113 const Expression &
2114 ExpressionCast::get_expression() const
2115 { return *expression; }
2116 ///////////////////////////////////////////////////
2117 1580 ExpressionBinary::ExpressionBinary(
2118 Gyoji::owned<Expression> _expression_a,
2119 Gyoji::owned<Terminal> _operator_token,
2120 Gyoji::owned<Expression> _expression_b,
2121 OperationType _type
2122 1580 )
2123 4740 : SyntaxNode(NONTERMINAL_expression_binary, this, _expression_a->get_source_ref())
2124 1580 , type(_type)
2125 1580 , expression_a(std::move(_expression_a))
2126 1580 , operator_token(std::move(_operator_token))
2127 1580 , operator_token2(nullptr)
2128 3160 , expression_b(std::move(_expression_b))
2129 {
2130 1580 add_child(*expression_a);
2131 1580 add_child(*operator_token);
2132 1580 add_child(*expression_b);
2133 1580 }
2134 ExpressionBinary::ExpressionBinary(
2135 Gyoji::owned<Expression> _expression_a,
2136 Gyoji::owned<Terminal> _operator_token,
2137 Gyoji::owned<Terminal> _operator_token2,
2138 Gyoji::owned<Expression> _expression_b,
2139 OperationType _type
2140 )
2141 : SyntaxNode(NONTERMINAL_expression_binary, this, _expression_a->get_source_ref())
2142 , type(_type)
2143 , expression_a(std::move(_expression_a))
2144 , operator_token(std::move(_operator_token))
2145 , operator_token2(std::move(_operator_token2))
2146 , expression_b(std::move(_expression_b))
2147 {
2148 add_child(*expression_a);
2149 add_child(*operator_token);
2150 add_child(*operator_token2);
2151 add_child(*expression_b);
2152 }
2153 1580 ExpressionBinary::~ExpressionBinary()
2154 1580 {}
2155 const Expression &
2156 658 ExpressionBinary::get_a() const
2157 658 { return *expression_a; }
2158 const ExpressionBinary::OperationType &
2159 658 ExpressionBinary::get_operator() const
2160 658 { return type; }
2161 const Gyoji::context::SourceReference &
2162 ExpressionBinary::get_operator_source_ref() const
2163 { return operator_token->get_source_ref(); }
2164 const Expression &
2165 658 ExpressionBinary::get_b() const
2166 658 { return *expression_b; }
2167 ///////////////////////////////////////////////////
2168 ExpressionTrinary::ExpressionTrinary(
2169 Gyoji::owned<Expression> _condition,
2170 Gyoji::owned<Terminal> _questionmark_token,
2171 Gyoji::owned<Expression> _if_expression,
2172 Gyoji::owned<Terminal> _colon_token,
2173 Gyoji::owned<Expression> _else_expression
2174 )
2175 : SyntaxNode(NONTERMINAL_expression_trinary, this, _condition->get_source_ref())
2176 , condition(std::move(_condition))
2177 , questionmark_token(std::move(_questionmark_token))
2178 , if_expression(std::move(_if_expression))
2179 , colon_token(std::move(_colon_token))
2180 , else_expression(std::move(_else_expression))
2181 {
2182 add_child(*condition);
2183 add_child(*questionmark_token);
2184 add_child(*if_expression);
2185 add_child(*colon_token);
2186 add_child(*else_expression);
2187 }
2188 ExpressionTrinary::~ExpressionTrinary()
2189 {}
2190 const Expression &
2191 ExpressionTrinary::get_condition() const
2192 { return *condition; }
2193 const Expression &
2194 ExpressionTrinary::get_if() const
2195 { return *if_expression; }
2196 const Expression &
2197 ExpressionTrinary::get_else() const
2198 { return *else_expression; }
2199 ///////////////////////////////////////////////////
2200 7662 Expression::Expression(Expression::ExpressionType _expression_type, const SyntaxNode & _sn)
2201 15324 : SyntaxNode(NONTERMINAL_expression, this, _sn.get_source_ref())
2202 7662 , expression_type(std::move(_expression_type))
2203 {
2204 7662 add_child(_sn);
2205 7662 }
2206 7662 Expression::~Expression()
2207 7662 {}
2208 const Expression::ExpressionType &
2209 2266 Expression::get_expression() const
2210 2266 { return expression_type; }
2211 ///////////////////////////////////////////////////
2212
2213 8 GlobalInitializerExpressionPrimary::GlobalInitializerExpressionPrimary(
2214 Gyoji::owned<Terminal> _equals_token,
2215 Gyoji::owned<Expression> _expression
2216 8 )
2217 24 : SyntaxNode(NONTERMINAL_global_initializer_expression_primary, this, _equals_token->get_source_ref())
2218 8 , equals_token(std::move(_equals_token))
2219 16 , expression(std::move(_expression))
2220 {
2221 8 add_child(*equals_token);
2222 8 add_child(*expression);
2223 8 }
2224
2225 8 GlobalInitializerExpressionPrimary::~GlobalInitializerExpressionPrimary()
2226 8 {}
2227
2228 const Expression &
2229 GlobalInitializerExpressionPrimary::get_expression() const
2230 { return *expression; };
2231
2232 ///////////////////////////////////////////////////
2233 16 StructInitializer::StructInitializer(
2234 Gyoji::owned<Terminal> _dot_token,
2235 Gyoji::owned<Terminal> _identifier_token,
2236 Gyoji::owned<GlobalInitializer> _global_initializer,
2237 Gyoji::owned<Terminal> _semicolon_token
2238 16 )
2239 48 : SyntaxNode(NONTERMINAL_struct_initializer, this, _dot_token->get_source_ref())
2240 16 , dot_token(std::move(_dot_token))
2241 16 , identifier_token(std::move(_identifier_token))
2242 16 , global_initializer(std::move(_global_initializer))
2243 32 , semicolon_token(std::move(_semicolon_token))
2244 {
2245 16 add_child(*dot_token);
2246 16 add_child(*identifier_token);
2247 16 add_child(*global_initializer);
2248 16 add_child(*semicolon_token);
2249 16 }
2250 16 StructInitializer::~StructInitializer()
2251 16 {}
2252 const GlobalInitializer &
2253 StructInitializer::get_initializer() const
2254 { return *global_initializer; }
2255
2256 ///////////////////////////////////////////////////
2257 8 StructInitializerList::StructInitializerList(const Gyoji::context::SourceReference & _source_ref)
2258 8 : SyntaxNode(NONTERMINAL_struct_initializer_list, this, _source_ref)
2259 8 {}
2260 8 StructInitializerList::~StructInitializerList()
2261 8 {}
2262 void
2263 16 StructInitializerList::add_initializer(Gyoji::owned<StructInitializer> initializer)
2264 {
2265 16 add_child(*initializer);
2266 16 initializers.push_back(std::move(initializer));
2267 16 }
2268 const std::vector<Gyoji::owned<StructInitializer>> &
2269 StructInitializerList::get_initializers() const
2270 {
2271 return initializers;
2272 }
2273
2274 ///////////////////////////////////////////////////
2275 8 GlobalInitializerAddressofExpressionPrimary::GlobalInitializerAddressofExpressionPrimary(
2276 Gyoji::owned<Terminal> _equals_token,
2277 Gyoji::owned<Terminal> _addressof_token,
2278 Gyoji::owned<Expression> _expression
2279 8 )
2280 24 : SyntaxNode(NONTERMINAL_global_initializer_addressof_expression_primary, this, _equals_token->get_source_ref())
2281 8 , equals_token(std::move(_equals_token))
2282 8 , addressof_token(std::move(_addressof_token))
2283 16 , expression(std::move(_expression))
2284 {
2285 8 add_child(*equals_token);
2286 8 add_child(*addressof_token);
2287 8 add_child(*expression);
2288 8 }
2289 8 GlobalInitializerAddressofExpressionPrimary::~GlobalInitializerAddressofExpressionPrimary()
2290 8 {}
2291 const Expression &
2292 GlobalInitializerAddressofExpressionPrimary::get_expression() const
2293 { return *expression; };
2294
2295
2296 ///////////////////////////////////////////////////
2297 8 GlobalInitializerStructInitializerList::GlobalInitializerStructInitializerList(
2298 Gyoji::owned<Terminal> _equals_token,
2299 Gyoji::owned<Terminal> _brace_l_token,
2300 Gyoji::owned<StructInitializerList> _struct_initializer,
2301 Gyoji::owned<Terminal> _brace_r_token
2302 8 )
2303 24 : SyntaxNode(NONTERMINAL_global_initializer_struct_initializer_list, this, _equals_token->get_source_ref())
2304 8 , equals_token(std::move(_equals_token))
2305 8 , brace_l_token(std::move(_brace_l_token))
2306 8 , struct_initializer(std::move(_struct_initializer))
2307 16 , brace_r_token(std::move(_brace_r_token))
2308 {
2309 8 add_child(*equals_token);
2310 8 add_child(*brace_l_token);
2311 8 add_child(*struct_initializer);
2312 8 add_child(*brace_r_token);
2313 8 }
2314 8 GlobalInitializerStructInitializerList::~GlobalInitializerStructInitializerList()
2315 8 {}
2316 const StructInitializerList &
2317 GlobalInitializerStructInitializerList::get_struct_initializer() const
2318 { return *struct_initializer; }
2319
2320 ///////////////////////////////////////////////////
2321 24 GlobalInitializer::GlobalInitializer(GlobalInitializer::GlobalInitializerType _initializer, const SyntaxNode & _sn)
2322 48 : SyntaxNode(NONTERMINAL_global_initializer, this, _sn.get_source_ref())
2323 24 , initializer(std::move(_initializer))
2324 {
2325 24 add_child(_sn);
2326 24 }
2327 116 GlobalInitializer::GlobalInitializer(const Gyoji::context::SourceReference & _source_ref)
2328 232 : SyntaxNode(NONTERMINAL_global_initializer, this, _source_ref)
2329 116 , initializer(nullptr)
2330 116 {}
2331 140 GlobalInitializer::~GlobalInitializer()
2332 140 {}
2333 const GlobalInitializer::GlobalInitializerType &
2334 GlobalInitializer::get_initializer() const
2335 { return initializer; }
2336
2337
2338 ///////////////////////////////////////////////////
2339 124 FileStatementGlobalDefinition::FileStatementGlobalDefinition(
2340 Gyoji::owned<AccessModifier> _access_modifier,
2341 Gyoji::owned<UnsafeModifier> _unsafe_modifier,
2342 Gyoji::owned<TypeSpecifier> _type_specifier,
2343 Gyoji::owned<Terminal> _name,
2344 Gyoji::owned<GlobalInitializer> _global_initializer,
2345 Gyoji::owned<Terminal> _semicolon
2346 124 )
2347 372 : SyntaxNode(NONTERMINAL_file_statement_global_definition, this, _access_modifier->get_source_ref())
2348 124 , access_modifier(std::move(_access_modifier))
2349 124 , unsafe_modifier(std::move(_unsafe_modifier))
2350 124 , type_specifier(std::move(_type_specifier))
2351 124 , name(std::move(_name))
2352 124 , global_initializer(std::move(_global_initializer))
2353 248 , semicolon(std::move(_semicolon))
2354 {
2355 124 add_child(*access_modifier);
2356 124 add_child(*unsafe_modifier);
2357 124 add_child(*type_specifier);
2358 124 add_child(*name);
2359 124 add_child(*global_initializer);
2360 124 add_child(*semicolon);
2361 124 }
2362
2363 124 FileStatementGlobalDefinition::~FileStatementGlobalDefinition()
2364 124 {}
2365
2366 const AccessModifier &
2367 4 FileStatementGlobalDefinition::get_access_modifier() const
2368 4 { return *access_modifier; }
2369 const UnsafeModifier &
2370 FileStatementGlobalDefinition::get_unsafe_modifier() const
2371 { return *unsafe_modifier; }
2372 const TypeSpecifier &
2373 8 FileStatementGlobalDefinition::get_type_specifier() const
2374 8 { return *type_specifier; }
2375 const std::string &
2376 8 FileStatementGlobalDefinition::get_name() const
2377 8 { return name->get_value(); }
2378 const SourceReference &
2379 FileStatementGlobalDefinition::get_name_source_ref() const
2380 { return name->get_source_ref(); }
2381 const GlobalInitializer &
2382 FileStatementGlobalDefinition::get_global_initializer() const
2383 { return *global_initializer; }
2384
2385 ///////////////////////////////////////////////////
2386 118 NamespaceDeclaration::NamespaceDeclaration(
2387 Gyoji::owned<AccessModifier> _access_modifier,
2388 Gyoji::owned<Terminal> _namespace_token,
2389 Gyoji::owned<Terminal> _identifier_token
2390 118 )
2391 354 : SyntaxNode(NONTERMINAL_namespace_declaration, this, _access_modifier->get_source_ref())
2392 118 , access_modifier(std::move(_access_modifier))
2393 118 , namespace_token(std::move(_namespace_token))
2394 236 , identifier_token(std::move(_identifier_token))
2395 {
2396 118 add_child(*access_modifier);
2397 118 add_child(*namespace_token);
2398 118 add_child(*identifier_token);
2399 118 }
2400 118 NamespaceDeclaration::~NamespaceDeclaration()
2401 118 {}
2402 const AccessModifier &
2403 NamespaceDeclaration::get_access_modifier() const
2404 { return *access_modifier; }
2405 const Terminal &
2406 NamespaceDeclaration::get_name() const
2407 { return *identifier_token; }
2408
2409 ///////////////////////////////////////////////////
2410 118 FileStatementNamespace::FileStatementNamespace(
2411 Gyoji::owned<NamespaceDeclaration> _namespace_declaration,
2412 Gyoji::owned<Terminal> _brace_l_token,
2413 Gyoji::owned<FileStatementList> _file_statement_list,
2414 Gyoji::owned<Terminal> _brace_r_token,
2415 Gyoji::owned<Terminal> _semicolon_token
2416 118 )
2417 354 : SyntaxNode(NONTERMINAL_file_statement_namespace, this, _namespace_declaration->get_source_ref())
2418 118 , namespace_declaration(std::move(_namespace_declaration))
2419 118 , brace_l_token(std::move(_brace_l_token))
2420 118 , file_statement_list(std::move(_file_statement_list))
2421 118 , brace_r_token(std::move(_brace_r_token))
2422 236 , semicolon_token(std::move(_semicolon_token))
2423 {
2424 118 add_child(*namespace_declaration);
2425 118 add_child(*brace_l_token);
2426 118 add_child(*file_statement_list);
2427 118 add_child(*brace_r_token);
2428 118 add_child(*semicolon_token);
2429 118 }
2430 118 FileStatementNamespace::~FileStatementNamespace()
2431 118 {}
2432 const NamespaceDeclaration & FileStatementNamespace::get_declaration() const
2433 { return *namespace_declaration;}
2434
2435 24 const FileStatementList & FileStatementNamespace::get_statement_list() const
2436 24 { return *file_statement_list;}
2437
2438 ///////////////////////////////////////////////////
2439
2440 12 UsingAs::UsingAs(
2441 Gyoji::owned<Terminal> _as_token,
2442 Gyoji::owned<Terminal> _identifier_token
2443 12 )
2444 36 : SyntaxNode(NONTERMINAL_using_as, this, _as_token->get_source_ref())
2445 12 , aas(true)
2446 12 , as_token(std::move(_as_token))
2447 24 , identifier_token(std::move(_identifier_token))
2448 {
2449 12 using_name = identifier_token->get_value();
2450 12 add_child(*as_token);
2451 12 add_child(*identifier_token);
2452 12 }
2453 34 UsingAs::UsingAs(const Gyoji::context::SourceReference & _source_ref)
2454 68 : SyntaxNode(NONTERMINAL_using_as, this, _source_ref)
2455 34 , aas(false)
2456 34 , as_token(nullptr)
2457 68 , identifier_token(nullptr)
2458 {
2459 34 using_name = "";
2460 34 }
2461 46 UsingAs::~UsingAs()
2462 46 {}
2463 const std::string &
2464 46 UsingAs::get_using_name() const
2465 46 { return using_name; }
2466 bool
2467 UsingAs::is_as() const
2468 { return aas; }
2469 const SourceReference &
2470 UsingAs::get_using_name_source_ref() const
2471 { return identifier_token->get_source_ref(); }
2472
2473 46 FileStatementUsing::FileStatementUsing(
2474 Gyoji::owned<AccessModifier> _access_modifier,
2475 Gyoji::owned<Terminal> _using,
2476 Gyoji::owned<Terminal> _namespace,
2477 Gyoji::owned<Terminal> _namespace_name,
2478 Gyoji::owned<UsingAs> _using_as,
2479 46 Gyoji::owned<Terminal> _semicolon)
2480 138 : SyntaxNode(NONTERMINAL_file_statement_using, this, _access_modifier->get_source_ref())
2481 46 , using_token(std::move(_using))
2482 46 , namespace_token(std::move(_namespace))
2483 46 , namespace_name_token(std::move(_namespace_name))
2484 46 , using_as(std::move(_using_as))
2485 92 , semicolon_token(std::move(_semicolon))
2486 {
2487 46 add_child(*using_token);
2488 46 add_child(*namespace_token);
2489 46 add_child(*namespace_name_token);
2490 46 add_child(*using_as);
2491 46 add_child(*semicolon_token);
2492 46 }
2493 46 FileStatementUsing::~FileStatementUsing()
2494 46 {}
2495 const AccessModifier &
2496 FileStatementUsing::get_access_modifier() const
2497 { return *access_modifier; }
2498 std::string
2499 FileStatementUsing::get_namespace() const
2500 { return namespace_name_token->get_fully_qualified_name(); }
2501 const UsingAs &
2502 FileStatementUsing::get_using_as() const
2503 { return *using_as; }
2504
2505
2506 1280 FileStatement::FileStatement(FileStatementType _statement, const SyntaxNode & _sn)
2507 2560 : SyntaxNode(NONTERMINAL_file_statement, this, _sn.get_source_ref())
2508 1280 , statement(std::move(_statement))
2509 {
2510 1280 add_child(_sn);
2511 1280 }
2512 1280 FileStatement::~FileStatement()
2513 1280 {}
2514 const FileStatement::FileStatementType &
2515 756 FileStatement::get_statement() const
2516 {
2517 756 return statement;
2518 }
2519
2520
2521 342 FileStatementList::FileStatementList(const Gyoji::context::SourceReference & _source_ref)
2522 684 : SyntaxNode(NONTERMINAL_file_statement_list, this, _source_ref)
2523 342 , yyeof(nullptr)
2524 342 {}
2525 18 FileStatementList::FileStatementList(Gyoji::owned<Terminal> _yyeof)
2526 54 : SyntaxNode(NONTERMINAL_file_statement_list, this, _yyeof->get_source_ref())
2527 18 , yyeof(std::move(_yyeof))
2528 {
2529 18 add_child(*yyeof);
2530 18 }
2531 360 FileStatementList::~FileStatementList()
2532 360 {}
2533 const std::vector<Gyoji::owned<FileStatement>> &
2534 128 FileStatementList::get_statements() const
2535 128 { return statements; }
2536 void
2537 1280 FileStatementList::add_statement(Gyoji::owned<FileStatement> statement)
2538 {
2539 1280 add_child(*statement);
2540 1280 statements.push_back(std::move(statement));
2541 1280 }
2542
2543 240 TranslationUnit::TranslationUnit(
2544 Gyoji::owned<FileStatementList> _file_statement_list,
2545 240 Gyoji::owned<Terminal> _yyeof_token)
2546 720 : SyntaxNode(NONTERMINAL_translation_unit, this, _yyeof_token->get_source_ref())
2547 240 , file_statement_list(std::move(_file_statement_list))
2548 480 , yyeof_token(std::move(_yyeof_token))
2549 {
2550 240 add_child(*file_statement_list);
2551 240 add_child(*yyeof_token);
2552 240 }
2553 240 TranslationUnit::~TranslationUnit()
2554 240 {}
2555
2556 const std::vector<Gyoji::owned<FileStatement>> &
2557 104 TranslationUnit::get_statements() const
2558 {
2559 104 return file_statement_list->get_statements();
2560 }
2561