00001 00002 /* 00003 pbrt source code Copyright(c) 1998-2007 Matt Pharr and Greg Humphreys. 00004 00005 This file is part of pbrt. 00006 00007 pbrt is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. Note that the text contents of 00011 the book "Physically Based Rendering" are *not* licensed under the 00012 GNU GPL. 00013 00014 pbrt is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program. If not, see <http://www.gnu.org/licenses/>. 00021 00022 */ 00023 00024 // parser.cpp* 00025 #include "pbrt.h" 00026 // Parsing Global Interface 00027 COREDLL 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("PBRT_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 } 00048 current_file = ""; 00049 line_num = 0; 00050 return (yyin != NULL); 00051 }