| 446 | } |
| 447 | |
| 448 | ConcreteNodeListPtr ScriptParser::parseChunk( const ScriptTokenListPtr &tokens, |
| 449 | const String &sourceFile ) |
| 450 | { |
| 451 | // MEMCATEGORY_GENERAL because SharedPtr can only free using that category |
| 452 | ConcreteNodeListPtr nodes( OGRE_NEW_T( ConcreteNodeList, MEMCATEGORY_GENERAL )(), |
| 453 | SPFM_DELETE_T ); |
| 454 | |
| 455 | ConcreteNodePtr node; |
| 456 | const ScriptToken *token = 0; |
| 457 | for( ScriptTokenList::const_iterator i = tokens->begin(); i != tokens->end(); ++i ) |
| 458 | { |
| 459 | token = &*i; |
| 460 | |
| 461 | switch( token->type ) |
| 462 | { |
| 463 | case TID_VARIABLE: |
| 464 | node = ConcreteNodePtr( OGRE_NEW ConcreteNode() ); |
| 465 | node->file = sourceFile; |
| 466 | node->line = token->line; |
| 467 | node->parent = 0; |
| 468 | node->token = token->lexeme(); |
| 469 | node->type = CNT_VARIABLE; |
| 470 | break; |
| 471 | case TID_WORD: |
| 472 | node = ConcreteNodePtr( OGRE_NEW ConcreteNode() ); |
| 473 | node->file = sourceFile; |
| 474 | node->line = token->line; |
| 475 | node->parent = 0; |
| 476 | node->token = token->lexeme(); |
| 477 | node->type = CNT_WORD; |
| 478 | break; |
| 479 | case TID_QUOTE: |
| 480 | node = ConcreteNodePtr( OGRE_NEW ConcreteNode() ); |
| 481 | node->file = sourceFile; |
| 482 | node->line = token->line; |
| 483 | node->parent = 0; |
| 484 | node->token = token->lexeme( true ); |
| 485 | node->type = CNT_QUOTE; |
| 486 | break; |
| 487 | default: |
| 488 | OGRE_EXCEPT( Exception::ERR_INVALID_STATE, |
| 489 | Ogre::String( "unexpected token" ) + token->lexeme() + " at line " + |
| 490 | Ogre::StringConverter::toString( token->line ), |
| 491 | "ScriptParser::parseChunk" ); |
| 492 | } |
| 493 | |
| 494 | if( node ) |
| 495 | nodes->push_back( node ); |
| 496 | } |
| 497 | |
| 498 | return nodes; |
| 499 | } |
| 500 | |
| 501 | ScriptToken *ScriptParser::getToken( ScriptTokenList::iterator i, ScriptTokenList::iterator end, |
| 502 | int offset ) |
no test coverage detected