main.c

00001 /* File:      main.c -- the main function for stand-alone 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: main.c,v 1.2 2001/07/01 21:52:54 gmkp Exp $
00022 ** 
00023 */
00024 
00025 
00026 #include <stdio.h>
00027 
00028 extern FILE* yyin;
00029 extern FILE* yyout;
00030 extern int yyparse();
00031 extern int num_errs;
00032 
00033 char* fn_source;
00034 char* fn_target;
00035 FILE* error_file;
00036 
00037 int main(int argc, char* argv[])
00038 {
00039     if (argc != 2) {
00040         fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
00041         exit(1);
00042     }
00043 
00044     if (strcmp(argv[1], "-") == 0) {
00045         yyin = stdin;
00046         fn_source = "";
00047     } else if ((yyin = fopen(argv[1], "r")) == NULL) {
00048         fprintf(stderr, "Error in opening file %s!\n", argv[1]);
00049         exit(1);
00050     } else {
00051         fn_source = argv[1];
00052     }
00053 
00054     yyout = stdout;
00055     error_file = stderr;
00056 
00057     if (yyparse()) {
00058         printf("%s contains one or more syntax errors.\n", argv[1]);
00059     }
00060 
00061     return 0;
00062 }

Generated on Wed Jul 26 13:30:46 2006 for XSB by  doxygen 1.4.5