/* G-Cows - scripting language for creation of web sites Copyright (C) 2002, 2003, 2004, 2005, 2006 Andrea Sozzi This file is part of G-Cows. G-Cows is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. G-Cows is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include //#include #include "common.H" #include "error.H" #include "cows_options.H" //#include "file_utils.H" #include "language.H" #define PROGRAM_NAME "cows" #define AUTHORS "Andrea Sozzi" using namespace std; extern FILE *yyin; extern int yyparse (void); Exec_tree *tree; int main (int argc, char *argv[]) { setlocale (LC_ALL, ""); Cows_opt opts (argc, argv); string input = opts.get_opt (Cows_opt::input); string output = opts.get_opt (Cows_opt::output); string report = opts.get_opt (Cows_opt::report_file); tree = new Exec_tree (input, output, opts.get_opt (Cows_opt::root_dir), opts.get_opt (Cows_opt::noext)); string var; while ( (var = opts.get_next_var ()) != "" ) tree->init_var (var); /* File checks for input and report files are done within Cows_opt class constructore so we can safely assume that these files are correctly open at this stage */ if (input == "-") Msg::inst()->set_parsed_file (""); else { // Set (f)lex's input buffer yyin = opts.get_input_file (); if (set_f_w_dir (input.c_str ()) ) Msg::inst()->sys_fatal ( string ("can't change directory to ") + get_dir_from_file_name (input), get_dir_from_file_name (input)); Msg::inst()->set_parsed_file (input); } // Parse yyparse (); Msg::inst()->erase_buffer (); // Output & Report // opts.dump_output (tree->get_output()); opts.dump_output ( ((tree->get_output()).str ()).c_str() ); opts.dump_report (input, output, Msg::inst()->get_n_warnings (), Msg::inst()->get_n_errors () ); return EXIT_SUCCESS; }