BNF:1: IMPORT ::= 'import' TYPE '&'? IDENTIFIER PARAMLIST FUNCATTR 'from' STRING ';'
| 2519 | |
| 2520 | // BNF:1: IMPORT ::= 'import' TYPE '&'? IDENTIFIER PARAMLIST FUNCATTR 'from' STRING ';' |
| 2521 | asCScriptNode *asCParser::ParseImport() |
| 2522 | { |
| 2523 | asCScriptNode *node = CreateNode(snImport); |
| 2524 | if( node == 0 ) return 0; |
| 2525 | |
| 2526 | sToken t; |
| 2527 | GetToken(&t); |
| 2528 | if( t.type != ttImport ) |
| 2529 | { |
| 2530 | Error(ExpectedToken(asCTokenizer::GetDefinition(ttImport)), &t); |
| 2531 | Error(InsteadFound(t), &t); |
| 2532 | return node; |
| 2533 | } |
| 2534 | |
| 2535 | node->SetToken(&t); |
| 2536 | node->UpdateSourcePos(t.pos, t.length); |
| 2537 | |
| 2538 | node->AddChildLast(ParseFunctionDefinition()); |
| 2539 | if( isSyntaxError ) return node; |
| 2540 | |
| 2541 | GetToken(&t); |
| 2542 | if( t.type != ttIdentifier ) |
| 2543 | { |
| 2544 | Error(ExpectedToken(FROM_TOKEN), &t); |
| 2545 | Error(InsteadFound(t), &t); |
| 2546 | return node; |
| 2547 | } |
| 2548 | |
| 2549 | tempString.Assign(&script->code[t.pos], t.length); |
| 2550 | if( tempString != FROM_TOKEN ) |
| 2551 | { |
| 2552 | Error(ExpectedToken(FROM_TOKEN), &t); |
| 2553 | Error(InsteadFound(t), &t); |
| 2554 | return node; |
| 2555 | } |
| 2556 | |
| 2557 | node->UpdateSourcePos(t.pos, t.length); |
| 2558 | |
| 2559 | GetToken(&t); |
| 2560 | if( t.type != ttStringConstant ) |
| 2561 | { |
| 2562 | Error(TXT_EXPECTED_STRING, &t); |
| 2563 | Error(InsteadFound(t), &t); |
| 2564 | return node; |
| 2565 | } |
| 2566 | |
| 2567 | asCScriptNode *mod = CreateNode(snConstant); |
| 2568 | if( mod == 0 ) return 0; |
| 2569 | |
| 2570 | node->AddChildLast(mod); |
| 2571 | |
| 2572 | mod->SetToken(&t); |
| 2573 | mod->UpdateSourcePos(t.pos, t.length); |
| 2574 | |
| 2575 | GetToken(&t); |
| 2576 | if( t.type != ttEndStatement ) |
| 2577 | { |
| 2578 | Error(ExpectedToken(asCTokenizer::GetDefinition(ttEndStatement)), &t); |
nothing calls this directly
no test coverage detected