00001 /* File: driver.c -- driver for the parser 00002 ** Author(s): Yifei Dong 00003 ** Contact: lmc@cs.sunysb.edu 00004 ** 00005 ** Copyright (C) SUNY at Stony Brook, 1998-2000 00006 ** 00007 ** XMC is free software; you can redistribute it and/or modify it under the 00008 ** terms of the GNU Library General Public License as published by the Free 00009 ** Software Foundation; either version 2 of the License, or (at your option) 00010 ** any later version. 00011 ** 00012 ** XMC is distributed in the hope that it will be useful, but WITHOUT ANY 00013 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 ** FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for 00015 ** more details. 00016 ** 00017 ** You should have received a copy of the GNU Library General Public License 00018 ** along with XMC; if not, write to the Free Software Foundation, 00019 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 ** 00021 ** $Id: driver.c,v 1.2 2001/07/01 21:52:54 gmkp Exp $ 00022 ** 00023 */ 00024 00025 #include <stdio.h> 00026 #include <string.h> 00027 00028 extern FILE *yyin; 00029 extern FILE* error_file; 00030 extern int yyparse(); 00031 00032 extern int line_no, char_no; 00033 extern char* yytext; 00034 00035 extern char* fn_source; 00036 int num_errs; 00037 00038 void warning(char* msg, char* arg) 00039 { 00040 fprintf(error_file, "%s:%d/%d: ", 00041 fn_source, line_no, char_no); 00042 fprintf(error_file, msg, arg); 00043 fprintf(error_file, "\n"); 00044 num_errs++; 00045 } 00046 00047 int yyerror(char *errtype) 00048 { 00049 fprintf(error_file, "%s:%d/%d: %s near token `%s'.\n", 00050 fn_source, 00051 line_no, char_no, errtype, yytext); 00052 num_errs++; 00053 return 0; 00054 }