BNF:4: TYPE ::= 'const'? SCOPE DATATYPE TEMPLTYPELIST? ( ('[' ']') | ('@' 'const'?) )
| 494 | |
| 495 | // BNF:4: TYPE ::= 'const'? SCOPE DATATYPE TEMPLTYPELIST? ( ('[' ']') | ('@' 'const'?) )* |
| 496 | asCScriptNode *asCParser::ParseType(bool allowConst, bool allowVariableType, bool allowAuto) |
| 497 | { |
| 498 | asCScriptNode *node = CreateNode(snDataType); |
| 499 | if( node == 0 ) return 0; |
| 500 | |
| 501 | sToken t; |
| 502 | |
| 503 | if( allowConst ) |
| 504 | { |
| 505 | GetToken(&t); |
| 506 | RewindTo(&t); |
| 507 | if( t.type == ttConst ) |
| 508 | { |
| 509 | node->AddChildLast(ParseToken(ttConst)); |
| 510 | if( isSyntaxError ) return node; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | // Parse scope prefix |
| 515 | ParseOptionalScope(node); |
| 516 | |
| 517 | // Parse the actual type |
| 518 | node->AddChildLast(ParseDataType(allowVariableType, allowAuto)); |
| 519 | if( isSyntaxError ) return node; |
| 520 | |
| 521 | // If the datatype is a template type, then parse the subtype within the < > |
| 522 | GetToken(&t); |
| 523 | RewindTo(&t); |
| 524 | asCScriptNode *type = node->lastChild; |
| 525 | tempString.Assign(&script->code[type->tokenPos], type->tokenLength); |
| 526 | if( engine->IsTemplateType(tempString.AddressOf()) && t.type == ttLessThan ) |
| 527 | { |
| 528 | ParseTemplTypeList(node); |
| 529 | if (isSyntaxError) return node; |
| 530 | } |
| 531 | |
| 532 | // Parse [] and @ |
| 533 | GetToken(&t); |
| 534 | RewindTo(&t); |
| 535 | while( t.type == ttOpenBracket || t.type == ttHandle) |
| 536 | { |
| 537 | if( t.type == ttOpenBracket ) |
| 538 | { |
| 539 | node->AddChildLast(ParseToken(ttOpenBracket)); |
| 540 | if( isSyntaxError ) return node; |
| 541 | |
| 542 | GetToken(&t); |
| 543 | if( t.type != ttCloseBracket ) |
| 544 | { |
| 545 | Error(ExpectedToken("]"), &t); |
| 546 | Error(InsteadFound(t), &t); |
| 547 | return node; |
| 548 | } |
| 549 | } |
| 550 | else |
| 551 | { |
| 552 | node->AddChildLast(ParseToken(ttHandle)); |
| 553 | if( isSyntaxError ) return node; |
nothing calls this directly
no test coverage detected