home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.parl.clemson.edu
/
2015-02-07.ftp.parl.clemson.edu.tar
/
ftp.parl.clemson.edu
/
pub
/
coven
/
coven-utils-1.1.tgz
/
coven-utils-1.1.tar
/
utils
/
coven-language
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
2003-01-28
|
3KB
|
133 lines
/*
* (C) 2001 Clemson University
*
* See COPYING in top-level directory.
*/
#include <stdio.h>
#include <getopt.h>
#include <Coven_lang.h>
#include <symbol.h>
static void initialize();
static void parse_args(int argc, char **argv);
static void finalize();
/*
* Global Variables
*/
extern FILE *yyin;
int input_file_flag = 0;
int out_file_flag = 0;
FILE *out_file;
int line = 1;
main(int argc, char **argv)
{
printf("NOTES / TODO:\n");
printf("\tParser does not allow for specifying user defined types.\n");
printf("\t does not allow for arguments to modules to be arrays {,,}\n");
printf("\t does not do any type checking\n");
printf("\t does not always do symbol checking (symbol prev. defined.)\n");
printf("\t does not handle 'if' statements or 'while' loops.\n");
printf("\t does not handle ADA-style local_binding=global_binding\n");
printf("\t module arguments.\n");
printf("\t does not allow 'for' loops to have a single module\n");
printf("\t inside of them.\n");
initialize();
parse_args(argc, argv);
yyparse();
finalize();
}
static void initialize()
{
sym_ent_p sym;
init_symbol_table();
sym = symenter("int", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("uint", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("string", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("float", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("double", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("char", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("uchar", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("short", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("ushort", NULL, TYPE_TYPE);
sym->type = TYPE_TYPE;
sym = symenter("MEDEA_BODY", NULL, TYPE_TYPE);
}
static void parse_args(int argc, char **argv)
{
int c;
int digit_optind = 0;
while(1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
/* {"option_name", has_arg, *flag, val}, */
{"option_name", 0, NULL, 0},
{0, 0, 0, 0}
};
c = getopt_long ( argc, argv, "i:o:", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0 : /* a long option */
break;
case 'i' : /* setup input file */
yyin = fopen(optarg,"r");
input_file_flag = 1;
break;
case 'o' : /* set output file */
out_file = fopen(optarg,"w");
out_file_flag = 1;
break;
default:
fprintf(stderr,"%s: undefined option %c given\n", argv[0], c);
}
}
if(!input_file_flag)
{
fprintf(stderr, "Must specify input file with '-i' option.\n");
exit(-1);
}
if(!out_file_flag)
{
fprintf(stderr, "Must specify output file with '-o' option.\n");
exit(-1);
}
}
static void finalize()
{
fclose(out_file);
}
yyerror(s)
{
fprintf(stderr,"syntax error line %d: %s\n", line, s);
exit(1);
}
void produce_listing(int line, char *listing)
{
/* fprintf(stderr, "produce_listing\n"); /* */
}