MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / ParseImport

Method ParseImport

src/server/angelscript/angelscript/source/as_parser.cpp:2327–2392  ·  view source on GitHub ↗

BNF:1: IMPORT ::= 'import' TYPE ['&'] IDENTIFIER PARAMLIST FUNCATTR 'from' STRING ';'

Source from the content-addressed store, hash-verified

2325
2326// BNF:1: IMPORT ::= 'import' TYPE ['&'] IDENTIFIER PARAMLIST FUNCATTR 'from' STRING ';'
2327asCScriptNode *asCParser::ParseImport()
2328{
2329 asCScriptNode *node = CreateNode(snImport);
2330 if( node == 0 ) return 0;
2331
2332 sToken t;
2333 GetToken(&t);
2334 if( t.type != ttImport )
2335 {
2336 Error(ExpectedToken(asCTokenizer::GetDefinition(ttImport)), &t);
2337 Error(InsteadFound(t), &t);
2338 return node;
2339 }
2340
2341 node->SetToken(&t);
2342 node->UpdateSourcePos(t.pos, t.length);
2343
2344 node->AddChildLast(ParseFunctionDefinition());
2345 if( isSyntaxError ) return node;
2346
2347 GetToken(&t);
2348 if( t.type != ttIdentifier )
2349 {
2350 Error(ExpectedToken(FROM_TOKEN), &t);
2351 Error(InsteadFound(t), &t);
2352 return node;
2353 }
2354
2355 tempString.Assign(&script->code[t.pos], t.length);
2356 if( tempString != FROM_TOKEN )
2357 {
2358 Error(ExpectedToken(FROM_TOKEN), &t);
2359 Error(InsteadFound(t), &t);
2360 return node;
2361 }
2362
2363 node->UpdateSourcePos(t.pos, t.length);
2364
2365 GetToken(&t);
2366 if( t.type != ttStringConstant )
2367 {
2368 Error(TXT_EXPECTED_STRING, &t);
2369 Error(InsteadFound(t), &t);
2370 return node;
2371 }
2372
2373 asCScriptNode *mod = CreateNode(snConstant);
2374 if( mod == 0 ) return 0;
2375
2376 node->AddChildLast(mod);
2377
2378 mod->SetToken(&t);
2379 mod->UpdateSourcePos(t.pos, t.length);
2380
2381 GetToken(&t);
2382 if( t.type != ttEndStatement )
2383 {
2384 Error(ExpectedToken(asCTokenizer::GetDefinition(ttEndStatement)), &t);

Callers

nothing calls this directly

Calls 4

SetTokenMethod · 0.80
UpdateSourcePosMethod · 0.80
AddChildLastMethod · 0.80
AssignMethod · 0.80

Tested by

no test coverage detected