================ idCompiler::ParseDefs Called at the outer layer and when a local statement is hit ================ */
| 2527 | ================ |
| 2528 | */ |
| 2529 | void idCompiler::ParseDefs( void ) { |
| 2530 | idStr name; |
| 2531 | idTypeDef *type; |
| 2532 | idVarDef *def; |
| 2533 | idVarDef *oldscope; |
| 2534 | |
| 2535 | if ( CheckToken( ";" ) ) { |
| 2536 | // skip semicolons, which are harmless and ok syntax |
| 2537 | return; |
| 2538 | } |
| 2539 | |
| 2540 | type = ParseType(); |
| 2541 | if ( type == &type_scriptevent ) { |
| 2542 | type = ParseType(); |
| 2543 | ParseName( name ); |
| 2544 | ParseEventDef( type, name ); |
| 2545 | return; |
| 2546 | } |
| 2547 | |
| 2548 | ParseName( name ); |
| 2549 | |
| 2550 | if ( type == &type_namespace ) { |
| 2551 | def = gameLocal.program.GetDef( type, name, scope ); |
| 2552 | if ( !def ) { |
| 2553 | def = gameLocal.program.AllocDef( type, name, scope, true ); |
| 2554 | } |
| 2555 | ParseNamespace( def ); |
| 2556 | } else if ( CheckToken( "::" ) ) { |
| 2557 | def = gameLocal.program.GetDef( NULL, name, scope ); |
| 2558 | if ( !def ) { |
| 2559 | Error( "Unknown object name '%s'", name.c_str() ); |
| 2560 | } |
| 2561 | ParseName( name ); |
| 2562 | oldscope = scope; |
| 2563 | scope = def; |
| 2564 | |
| 2565 | ExpectToken( "(" ); |
| 2566 | ParseFunctionDef( type, name.c_str() ); |
| 2567 | scope = oldscope; |
| 2568 | } else if ( type == &type_object ) { |
| 2569 | ParseObjectDef( name.c_str() ); |
| 2570 | } else if ( CheckToken( "(" ) ) { // check for a function prototype or declaraction |
| 2571 | ParseFunctionDef( type, name.c_str() ); |
| 2572 | } else { |
| 2573 | ParseVariableDef( type, name.c_str() ); |
| 2574 | while( CheckToken( "," ) ) { |
| 2575 | ParseName( name ); |
| 2576 | ParseVariableDef( type, name.c_str() ); |
| 2577 | } |
| 2578 | ExpectToken( ";" ); |
| 2579 | } |
| 2580 | } |
| 2581 | |
| 2582 | /* |
| 2583 | ================ |