00001 #include "def.h"
00002
00003 int verbose;
00004 char *libdir;
00005
00006 static char* copyright = "copyright (c) 1988 Wm Leler";
00007
00008
00009
00010
00011
00012
00013
00014
00015 void
00016 main(argc, argv)
00017 int argc;
00018 char *argv[];
00019 {
00020 void parse();
00021 extern FILE *infile;
00022 extern char *infilename;
00023 extern int lineno;
00024 NODE *init();
00025 extern int learn;
00026 NODE *walk();
00027 void expr_print();
00028 void name_space_print();
00029 extern NAME_NODE *global_names;
00030 void graphics_close();
00031 extern int graphics;
00032 void st_mem_free();
00033 char *getenv();
00034
00035 int argno = 1;
00036 NODE *subject;
00037
00038
00039 if (!(libdir = getenv("BERTRAND"))) libdir = LIBDIR;
00040
00041 do {
00042 subject = init();
00043 if (argc==1) {
00044 infilename = "stdin";
00045 infile = stdin;
00046 parse();
00047 }
00048 else {
00049 infilename = argv[argno];
00050 infile = fopen(infilename, "r");
00051 if (NULL==infile) {
00052 fprintf(stderr, "can't open program file %s\n", infilename);
00053 exit(1);
00054 }
00055 parse();
00056 fclose(infile);
00057 }
00058
00059 lineno = 0;
00060 if (verbose) fprintf(stderr, "\n");
00061
00062 do {
00063 subject = walk(subject);
00064 } while (learn);
00065
00066 if (verbose && global_names->child) {
00067 fprintf(stderr, "\nglobal name space is: ");
00068 name_space_print(global_names);
00069 }
00070 if (verbose) fprintf(stderr, "\nfinal expression is: ");
00071 expr_print(subject);
00072 fprintf(stderr, "\n");
00073
00074 st_mem_free();
00075
00076 if (graphics) {
00077 fprintf(stderr, "Zap output window to continue...\n");
00078 graphics_close();
00079 }
00080
00081 } while(++argno<argc);
00082 }