main.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/* Main function for dlg version
*
* SOFTWARE RIGHTS
*
* We reserve no LEGAL rights to the Purdue Compiler Construction Tool
* Set (PCCTS) -- PCCTS is in the public domain. An individual or
* company may do whatever they wish with source code distributed with
* PCCTS or the code generated by PCCTS, including the incorporation of
* PCCTS, or its output, into commerical software.
*
* We encourage users to develop software with PCCTS. However, we do ask
* that credit is given to us for developing PCCTS. By "credit",
* we mean that if you incorporate our source code into one of your
* programs (commercial product, research project, or otherwise) that you
* acknowledge this fact somewhere in the documentation, research report,
* etc... If you like PCCTS and have developed a nice tool with the
* output, please mention that you developed it using PCCTS. In
* addition, we ask that this header remain intact in our source code.
* As long as these guidelines are kept, we expect to continue enhancing
* this system and expect to make other tools available as they are
* completed.
*
* DLG 1.33
* Will Cohen
* With mods by Terence Parr; AHPCRC, University of Minnesota
* 1989-2001
*/
#include <stdio.h>
#include "stdpccts.h"
char program[] = "dlg";
int numfiles = 0;
char *class_name = DEFAULT_CLASSNAME;
char *OutputDirectory = TopDirectory;
/* Option variables */
int comp_level = 0;
int interactive = FALSE;
int case_insensitive = FALSE;
int warn_ambig = FALSE;
#ifdef __USE_PROTOS
static int ci_strequ(char *a,char *b)
#else
static int ci_strequ(a,b)
char *a;
char *b;
#endif
{
for ( ;*a != 0 && *b != 0; a++, b++) {
}
return (*a == *b);
}
/* Option List Stuff */
#ifdef __USE_PROTOS
void p_comp0(void) {comp_level = 0;}
void p_cl_name(char *s, char *t)
{
if ( gen_cpp ) {
class_name = t;
}
else {
warning("-cl only valid in C++ mode; -cl ignored...",0);
}
}
void p_mode_file(char *s, char *t){mode_file=t;}
void p_outdir(char *s,char *t) {OutputDirectory=t;}
#else
void p_comp0() {comp_level = 0;}
void p_cl_name(s,t)
char *s, *t;
{
if ( gen_cpp ) {
class_name = t;
}
else {
warning("-cl only valid in C++ mode; -cl ignored...",0);
}
}
void p_mode_file(s,t) char *s,*t;{mode_file=t;}
void p_outdir(s,t) char *s,*t;{OutputDirectory=t;}
#endif
#ifdef __cplusplus
typedef void (*WildFunc)(...);
#else
typedef void (*WildFunc)();
#endif
typedef struct {
char *option;
int arg;
char *descr;
} Opt;
};
#ifdef __USE_PROTOS
#else
int argc;
char **argv;
#endif
{
Opt *p;
while ( argc-- > 0 )
{
p = options;
{
{
if ( p->arg )
{
argv++;
argc--;
}
else
break;
}
p++;
}
argv++;
}
}
#ifdef __USE_PROTOS
#else
int argc;
char *argv[];
#endif
{
init();
&(version[0]));
if ( argc == 1 )
{
while ( *(p->option) != '*' )
{
p->option,
p->descr);
p++;
}
}else{
if (interactive && gen_cpp) {
/*** MR21a This statement is wrong ! ***/
#if 0
#endif
}
if (input_stream) {
/* don't overwrite unless input okay */
if ( gen_cpp ) {
warning("output file implicit in C++ mode; ignored...",0);
}
}
else {
}
}
/* make sure that error reporting routines in grammar
know what the file really is */
/* make sure that reading and writing somewhere */
}
p_class_def2(); /* MR1 */
}
return 0; /* get rid of warning message MR1 */
}
/* initialize all the variables */
void
#ifdef __USE_PROTOS
init(void)
#else
init()
#endif
{
register int i;
#ifdef SPECIAL_INITS
special_inits(); /* MR1 */
#endif
used_chars = empty;
/* make the valid character set */
/* NOTE: MIN_CHAR is EOF */
/* NOTE: EOF is not quite a valid char, it is special. Skip it*/
for (i = 1; i<CHAR_RANGE; ++i){
set_orel(i,&normal_chars);
}
clear_hash();
/* NOTE: need to set this flag before the lexer starts getting */
/* tokens */
func_action = FALSE;
}
/* stuff that needs to be reset when a new automaton is being built */
void
#ifdef __USE_PROTOS
new_automaton_mode(void) /* MR1 */
#else
new_automaton_mode() /* MR1 */
#endif
{
clear_hash();
}