Commit 8ad1cf7d authored by dcw's avatar dcw
Browse files

moved opening/closing of files into make_declns;

added exports and globals sections to the parse language..
parent 88a01743
......@@ -21,6 +21,7 @@
#include "lexer.h"
#include "parser.h"
#include "decs.h"
#include "optimize.h"
#define MUSTBE(b) ASSERT(b,("Usage: datadec [-vpo] outfile [infile]\n"))
......@@ -30,15 +31,17 @@
#define IS_ANOTHER_ARG (argc > arg)
main( argc, argv ) int argc; char **argv;
#define CHUNKSIZE 10000
void main( argc, argv ) int argc; char **argv;
{
FILE *cfile, *hfile;
char tempname[256];
char *basename;
char *s;
declnlist declns;
int len;
int arg;
char exports[CHUNKSIZE], globals[CHUNKSIZE];
arg = 1;
NEED_ANOTHER_ARG;
......@@ -74,14 +77,6 @@ main( argc, argv ) int argc; char **argv;
basename[len-2] = '\0';
}
sprintf( tempname, "%s.c", basename );
cfile = fopen( tempname, "w" );
ASSERT( cfile != NULL, ("datadec: can't create '%s'\n",tempname) );
sprintf( tempname, "%s.h", basename );
hfile = fopen( tempname, "w" );
ASSERT( hfile != NULL, ("datadec: can't create '%s'\n",tempname) );
if( IS_ANOTHER_ARG ) {
lexfile = fopen( argv[arg], "r" );
ASSERT( lexfile != NULL,
......@@ -93,19 +88,21 @@ main( argc, argv ) int argc; char **argv;
REQUIRE_NO_MORE_ARGS;
if( parse_declns( &declns ) )
if( parse_data( exports, globals, &declns ) )
{
if( verbose )
{
printf( "datadec: declns are:\n\n" );
print_declnlist( declns );
printf( "exports = {%s}\n", exports );
printf( "globals = {%s}\n", globals );
}
make_declns( declns, cfile, hfile, basename );
optimize( declns );
make_declns( exports, globals, declns, basename );
} else
{
fprintf( stderr, "datadec: can't parse input properly\n" );
}
fclose( cfile );
fclose( hfile );
exit(0);
/*NOTREACHED*/
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment