00001 /*************************************************************************** 00002 * Copyright (C) 1998-2009 by authors (see AUTHORS.txt ) * 00003 * * 00004 * This file is part of LuxRender. * 00005 * * 00006 * Lux Renderer is free software; you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation; either version 3 of the License, or * 00009 * (at your option) any later version. * 00010 * * 00011 * Lux Renderer is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00018 * * 00019 * This project is based on PBRT ; see http://www.pbrt.org * 00020 * Lux Renderer website : http://www.luxrender.net * 00021 ***************************************************************************/ 00022 00023 // parser.cpp* 00024 #include "lux.h" 00025 #include "error.h" 00026 // Parsing Global Interface 00027 bool ParseFile(const char *filename) { 00028 extern FILE *yyin; 00029 extern int yyparse(void); 00030 extern string current_file; 00031 extern int line_num; 00032 /*extern int yydebug; 00033 00034 if (getenv("LUX_YYDEBUG") != NULL) 00035 yydebug = 1;*/ 00036 00037 if (strcmp(filename, "-") == 0) 00038 yyin = stdin; 00039 else 00040 yyin = fopen(filename, "r"); 00041 if (yyin != NULL) { 00042 current_file = filename; 00043 if (yyin == stdin) current_file = "<standard input>"; 00044 line_num = 1; 00045 yyparse(); 00046 if (yyin != stdin) fclose(yyin); 00047 } else { 00048 std::stringstream ss; 00049 ss<<"Unable to read scenefile '"<<filename<<"'"; 00050 luxError(LUX_NOFILE, LUX_SEVERE, ss.str ().c_str()); 00051 } 00052 00053 current_file = ""; 00054 line_num = 0; 00055 return (yyin != NULL); 00056 }