1 |
aw0a |
1 |
/* |
2 |
|
|
* Main program |
3 |
|
|
* by Tom Epperly |
4 |
|
|
* Part of Ascend |
5 |
|
|
* Version: $Revision: 1.28 $ |
6 |
|
|
* Version control file: $RCSfile: main.c,v $ |
7 |
|
|
* Date last modified: $Date: 1998/02/18 22:57:15 $ |
8 |
|
|
* Last modified by: $Author: ballan $ |
9 |
|
|
* |
10 |
|
|
* This file is part of the Ascend Language Interpreter. |
11 |
|
|
* |
12 |
|
|
* Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
13 |
|
|
* |
14 |
|
|
* The Ascend Language Interpreter is free software; you can redistribute |
15 |
|
|
* it and/or modify it under the terms of the GNU General Public License as |
16 |
|
|
* published by the Free Software Foundation; either version 2 of the |
17 |
|
|
* License, or (at your option) any later version. |
18 |
|
|
* |
19 |
|
|
* The Ascend Language Interpreter is distributed in hope that it will be |
20 |
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 |
|
|
* General Public License for more details. |
23 |
|
|
* |
24 |
|
|
* You should have received a copy of the GNU General Public License |
25 |
|
|
* along with the program; if not, write to the Free Software Foundation, |
26 |
|
|
* Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named |
27 |
|
|
* COPYING. |
28 |
|
|
*/ |
29 |
|
|
|
30 |
|
|
#include <stdio.h> |
31 |
|
|
#include <time.h> |
32 |
|
|
#include <string.h> |
33 |
|
|
#include <limits.h> |
34 |
|
|
#include <ctype.h> /* was compiler/actype.h */ |
35 |
johnpye |
399 |
#include <utilities/ascConfig.h> |
36 |
|
|
#include <utilities/ascMalloc.h> |
37 |
|
|
#include <utilities/ascEnvVar.h> |
38 |
|
|
#include <utilities/ascPanic.h> |
39 |
|
|
#include <general/list.h> |
40 |
|
|
#include <general/pool.h> |
41 |
|
|
#include "compiler.h" |
42 |
|
|
#include "ascCompiler.h" |
43 |
|
|
#include "module.h" |
44 |
|
|
#include "symtab.h" |
45 |
johnpye |
1211 |
|
46 |
|
|
|
47 |
johnpye |
399 |
#include "functype.h" |
48 |
|
|
#include "types.h" |
49 |
|
|
#include "instance_enum.h" |
50 |
|
|
#include "setinstval.h" |
51 |
|
|
#include "child.h" |
52 |
|
|
#include "type_desc.h" |
53 |
|
|
#include "stattypes.h" |
54 |
|
|
#include "slist.h" |
55 |
|
|
#include "scanner.h" |
56 |
|
|
#include "evaluate.h" |
57 |
|
|
#include "units.h" |
58 |
|
|
#include "typedef.h" |
59 |
|
|
#include "dump.h" |
60 |
|
|
#include "prototype.h" |
61 |
|
|
#include "slist.h" |
62 |
|
|
#include "typedef.h" |
63 |
|
|
#include "library.h" |
64 |
|
|
#include "arrayinst.h" |
65 |
|
|
#include "instance_name.h" |
66 |
|
|
#include "relation_type.h" |
67 |
|
|
#include "logical_relation.h" |
68 |
|
|
#include "find.h" |
69 |
|
|
#include "relation.h" |
70 |
|
|
#include "logrelation.h" |
71 |
|
|
#include "setinstval.h" |
72 |
|
|
#include "interface.h" |
73 |
|
|
#include "universal.h" |
74 |
|
|
#include "extfunc.h" |
75 |
|
|
#include "packages.h" /* user packages and functions */ |
76 |
|
|
#include "pending.h" |
77 |
|
|
#include "value_type.h" |
78 |
|
|
#include "temp.h" |
79 |
|
|
#include "forvars.h" |
80 |
aw0a |
1 |
|
81 |
|
|
#ifndef lint |
82 |
|
|
static CONST char MainDriverID[] = "$Id: main.c,v 1.28 1998/02/18 22:57:15 ballan Exp $"; |
83 |
|
|
#endif |
84 |
|
|
|
85 |
|
|
#ifdef YYDEBUG |
86 |
|
|
extern int zz_debug; |
87 |
|
|
#endif |
88 |
|
|
extern int zz_parse(); |
89 |
|
|
|
90 |
|
|
/* cmu hacks so we don't move binaries out from under testers */ |
91 |
|
|
/* if ZEPHYR == 0, hacks turned off */ |
92 |
|
|
#define ZEPHYR 0 |
93 |
|
|
/* who to tell, and who not to tell when he himself runs it */ |
94 |
|
|
#define ZNOTIFY "ballan" |
95 |
|
|
|
96 |
|
|
static |
97 |
|
|
void MainOpenModule(char *name) |
98 |
|
|
{ |
99 |
|
|
if (Asc_OpenModule(name,NULL)==NULL){ |
100 |
|
|
FPRINTF(ASCERR,"Unable to find module %s in search path. Goodbye.\n", |
101 |
|
|
name); |
102 |
|
|
exit(2);/*NOTREACHED*/ |
103 |
|
|
} |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
|
107 |
|
|
int main(int argc, char **argv) |
108 |
|
|
{ |
109 |
|
|
int c,errflg=0; |
110 |
|
|
char *filename; |
111 |
|
|
#if ZEPHYR |
112 |
|
|
char zbuf[1024]; |
113 |
|
|
#endif |
114 |
|
|
extern int optind,opterr; |
115 |
|
|
extern char *optarg; |
116 |
|
|
#ifdef YYDEBUG |
117 |
|
|
zz_debug=0; |
118 |
|
|
#endif |
119 |
|
|
while ((c = getopt(argc,argv,"d")) != EOF) { |
120 |
|
|
switch(c){ |
121 |
|
|
case 'd': |
122 |
|
|
#ifdef YYDEBUG |
123 |
|
|
zz_debug=1; |
124 |
|
|
#else |
125 |
|
|
FPRINTF(ASCERR,"Sorry this wasn't compiled with YYDEBUG defined.\n"); |
126 |
|
|
#endif |
127 |
|
|
break; |
128 |
|
|
case '?': |
129 |
|
|
errflg++; |
130 |
|
|
} |
131 |
|
|
} |
132 |
|
|
if (optind == (argc-1)){ |
133 |
|
|
filename=argv[optind]; |
134 |
|
|
} |
135 |
|
|
else errflg++; |
136 |
|
|
if (errflg) { |
137 |
|
|
FPRINTF(ASCERR,"usage: %s [-d] filename\n",argv[0]); |
138 |
|
|
exit(2);/*NOTREACHED*/ |
139 |
|
|
} |
140 |
|
|
PRINTF("ASCEND VERSION IV\n"); |
141 |
|
|
PRINTF("Compiler Implemention Version: 2.0\n"); |
142 |
|
|
PRINTF("Written by Tom Epperly\n"); |
143 |
|
|
PRINTF("Copyright(C) 1990, 1993, 1994 Thomas Guthrie Weidner Epperly\n"); |
144 |
|
|
PRINTF(" 1995, 1996 Kirk Andre Abbott, Benjamin Andrew Allan\n"); |
145 |
|
|
PRINTF(" 1997 Carnegie Mellon University\n"); |
146 |
|
|
PRINTF( |
147 |
|
|
"ASCEND comes with ABSOLUTELY NO WARRANTY; for details type `warranty'.\n"); |
148 |
|
|
PRINTF( |
149 |
|
|
"This is free software, and you are welcome to redistribute it under\n"); |
150 |
|
|
PRINTF("certain conditions; type `copying' for details.\n"); |
151 |
|
|
|
152 |
|
|
if( Asc_CompilerInit(1) != 0 ) { |
153 |
johnpye |
1064 |
ASC_PANIC("Asc_CompilerInit returned nonzero"); |
154 |
aw0a |
1 |
} |
155 |
|
|
|
156 |
|
|
/* |
157 |
|
|
* Import the value of ASCENDLIBRARY into the environment before |
158 |
|
|
* trying to read any modules. |
159 |
|
|
*/ |
160 |
jpye |
1524 |
Asc_ImportPathList(ASC_ENV_LIBRARY); |
161 |
aw0a |
1 |
|
162 |
|
|
MainOpenModule(filename); |
163 |
|
|
|
164 |
|
|
#if ZEPHYR |
165 |
|
|
/* |
166 |
|
|
* USER and HOST are not universally used, but we'll assume an mthomas setup |
167 |
|
|
*/ |
168 |
|
|
if (getenv("USER")!=NULL) { |
169 |
|
|
if ( strcmp(getenv("USER"),ZNOTIFY)!=0) { |
170 |
|
|
if (getenv("HOST") !=NULL) { |
171 |
|
|
sprintf(zbuf,"/usr/local/bin/zwrite -d -q %s -m %s@%s running %s", |
172 |
|
|
ZNOTIFY,getenv("USER"),getenv("HOST"), argv[0]); |
173 |
|
|
} else { |
174 |
|
|
sprintf(zbuf,"/usr/local/bin/zwrite -d -q %s -m %s running %s", |
175 |
|
|
ZNOTIFY,getenv("USER"), argv[0]); |
176 |
|
|
} |
177 |
|
|
} |
178 |
|
|
} else { |
179 |
|
|
sprintf(zbuf,"/usr/local/bin/zwrite -d -q %s -m %s %s", |
180 |
|
|
ZNOTIFY,"Somebody somewhere ran ", argv[0]); |
181 |
|
|
} |
182 |
|
|
system(zbuf); |
183 |
|
|
#endif |
184 |
|
|
|
185 |
|
|
zz_parse(); |
186 |
|
|
ascstatus("Memory status after parsing input file"); |
187 |
|
|
Interface(); /* call an interface */ |
188 |
|
|
ascstatus("Memory status after interface exits"); |
189 |
|
|
|
190 |
|
|
Asc_CompilerDestroy(); |
191 |
|
|
|
192 |
|
|
ascshutdown("Memory status just before exiting"); |
193 |
|
|
return 0; |
194 |
|
|
} |