STATIC void parseString( const char *str ) { /**/myassert( str != NULL ); for(;;) { while( isspace( *str ) ) ++str; switch( *str ) { case 0: return; case SWCHAR: case '-': str += 2; switch( str[-1] ) { case 'o': str = doOutput( str ); break; case 'd': str = doDebug( str ); break; case 'p': str = doParse( str ); break; case 'f': str = doFile( str ); break; case 'q': /* FALL THROUGH */ #if 0 case 'l': #endif case 'b': str = doToggle( str ); break; default: usage(); } if( !isBreakChar( *str ) ) usage(); break; case INCCHAR: str = doInclude( str + 1 ); break; case CMTCHAR: str = doComment( str + 1 ); break; default: str = addFile( str ); break; } } }
bool SceneLoader::buildScene(string filename) { buildEndlineTable(filename); ifstream file(filename.c_str()); string line; int lastPos = 0; while (findOpenParen(file)) { cout << "found open paren" << endl; file.tellg(); if (readCommand(file, line)) { if (line == "Include") { string instName; if (doInclude(file, instName)) { cout << "included " << instName << endl; } else { cout << "mangled include at "; curPos(cout, file.tellg()); cout << endl; } } else if (line == "Sphere") { string gname; if (doSphere(file, gname)) { cout << "read sphere " << gname << endl; } else { *err << "mangled sphere command at "; errLine(file.tellg()); } } else if (line == "Material") { string gname; if (doMaterial(file, gname)) { cout << "read material " << gname << endl; } else { *err << "mangled material command at "; errLine(file.tellg()); } } else if (line == "Light") { string gname; if (doLight(file, gname)) { cout << "read light " << gname << endl; } else { *err << "mangled light command at "; errLine(file.tellg()); } } else if (line == "Camera") { string gname; if (doCamera(file, gname)) { cout << "read camera " << gname << endl; } else { *err << "mangled camera command at "; errLine(file.tellg()); } } else if (line == "I") { *err << "Error: Instance commands must belong to a group, but I found in global scope at "; errLine(file.tellg()); /*string iname; // code to handle I at global scope (doesn't make much sense now that instance names skip the names table) if (doI(file, iname)) { cout << "got an instance named " << iname << endl; }*/ } else if (line == "G") { string iname; if (doG(file, iname)) { cout << "got a group named " << iname << endl; } } else if (line == "Render") { string iname; if (doRender(file, iname)) { cout << "did render " << iname << endl; } } else { *err << "command not recognized: " << line << endl; } findCloseParen(file); } else { } lastPos = file.tellg(); } return true; }