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