1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1986-11-24 20:42:13 +00:00
|
|
|
/* m a i n . c
|
|
|
|
*
|
|
|
|
* Contains the main program, the error reporting routine, and a routine
|
|
|
|
* to check wether a constraint consists only of space
|
|
|
|
*/
|
2006-07-22 12:28:20 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2019-02-18 16:44:39 +00:00
|
|
|
#include "Lpars.h"
|
1986-11-24 20:42:13 +00:00
|
|
|
|
|
|
|
extern int lineno, newline;
|
|
|
|
|
|
|
|
FILE *genc, *genh, *input;
|
|
|
|
static int nerrors;
|
|
|
|
char *linedir = "#line %d \"%s\"\n"; /* format of line directive */
|
|
|
|
char *inpfile;
|
|
|
|
|
2019-02-18 16:44:39 +00:00
|
|
|
extern void LLparse(void);
|
1986-11-24 20:42:13 +00:00
|
|
|
|
2019-02-18 16:44:39 +00:00
|
|
|
int main(int argc,char* argv[])
|
|
|
|
{
|
1986-11-24 20:42:13 +00:00
|
|
|
newline = 1;
|
2016-08-13 23:39:40 +00:00
|
|
|
if (argc != 3) {
|
|
|
|
fprintf(stderr,"Usage : %s targetoptimizerdescription outputdir\n",argv[0]);
|
1987-03-09 13:25:44 +00:00
|
|
|
exit(1);
|
1986-11-24 20:42:13 +00:00
|
|
|
}
|
|
|
|
if ((input = fopen(argv[1],"r")) == NULL) {
|
|
|
|
fprintf(stderr,"Fatal error : couldn't open %s\n",argv[1]);
|
1987-03-09 13:25:44 +00:00
|
|
|
exit(1);
|
2016-08-13 23:39:40 +00:00
|
|
|
}
|
|
|
|
if (chdir(argv[2]) != 0) {
|
|
|
|
fprintf(stderr,"Fatal error : couldn't chdir to %s\n",argv[2]);
|
|
|
|
exit(1);
|
1986-11-24 20:42:13 +00:00
|
|
|
}
|
|
|
|
if ((genc = fopen("gen.c","w")) == NULL) {
|
|
|
|
fputs("Fatal error : couldn't open gen.c\n",stderr);
|
1987-03-09 13:25:44 +00:00
|
|
|
exit(1);
|
1986-11-24 20:42:13 +00:00
|
|
|
}
|
|
|
|
if ((genh = fopen("gen.h","w")) == NULL) {
|
|
|
|
fputs("Fatal error : couldn't open gen.h\n",stderr);
|
1987-03-09 13:25:44 +00:00
|
|
|
exit(1);
|
1986-11-24 20:42:13 +00:00
|
|
|
}
|
|
|
|
inpfile = argv[1]; /* needed for line directives and errors */
|
|
|
|
LLparse();
|
1987-03-09 13:25:44 +00:00
|
|
|
exit(nerrors);
|
1986-11-24 20:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* VARARGS1 */
|
2019-02-18 16:44:39 +00:00
|
|
|
void error(char *s, char* s1)
|
|
|
|
{
|
1986-11-24 20:42:13 +00:00
|
|
|
nerrors++;
|
|
|
|
fprintf(stderr,"\"%s\", line %d: ",inpfile,lineno);
|
|
|
|
fprintf(stderr,s,s1);
|
|
|
|
putc('\n',stderr);
|
|
|
|
}
|
|
|
|
|
2019-02-18 16:44:39 +00:00
|
|
|
int onlyspace(register char* s)
|
|
|
|
{
|
1986-11-24 20:42:13 +00:00
|
|
|
|
|
|
|
while (*s) {
|
|
|
|
if (*s != ' ' && *s != '\t' && *s != '\n') return 0;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|