diff --git a/WEGA/contrib/ingres/dbs/src/eql/constants.h b/WEGA/contrib/ingres/dbs/src/eql/constants.h new file mode 100644 index 0000000..2a2c656 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/eql/constants.h @@ -0,0 +1,94 @@ +/* CONSTANTS.H -- manifest constants, operand and operator codes */ +/* */ +/* Defines: */ +/* op_codes for operands */ +/* Opflag's domain set */ +/* Type_spec's domain set */ + +/* Manifest constants used throughout EQL */ + +# define CONTINUE 1 /* "loop" flag for yylex */ +# ifdef MAXNAME +# undef MAXNAME +# endif +# define MAXNAME 13 /* maximum length for EQL */ + /* identifiers (or keywords) */ +# define MAXSTRING 255 /* maximum length for EQL strings */ +# define FILLCNT 110 /* length to fill lines */ + /* when in Fillmode */ + + +/* debugging info conditional compilation flag */ +# define xDEBUG /* on for "-c" and "-v" flags */ + + +/* Character types [cmap.c] */ + +# define EOF_TOK 0 /* end of parse input too */ +# define ALPHA 1 /* alphabetic or '_' */ +# define NUMBR 2 /* numeric */ +# define OPATR 3 /* other non control characters */ +# define PUNCT 4 /* white space */ +# define CNTRL 5 /* control-characters */ + + +/* Modes used in parser actions to distinguish contexts in which */ +/* the same syntax applies. Opflag is set to these modes. */ +/* */ +/* (There are some modes that are never referenced, but are useful */ +/* for extension). */ + + /* QL statements */ + +# define mdAPPEND 1 +# define mdCOPY 2 +# define mdCREATE 3 +# define mdDEFINE 4 +# define mdDELETE 5 +# define mdDESTROY 6 +# define mdHELP 7 +# define mdINDEX 8 +# define mdINTEGRITY 9 +# define mdMODIFY 10 +# define mdPRINT 11 +# define mdRANGE 12 +# define mdREPLACE 13 +# define mdRETRIEVE 14 +# define mdSAVE 15 +# define mdVIEW 16 +# define mdPROT 17 + + /* statements particular to EQL */ + +# define mdDECL 16 /* C - declaration */ +# define mdCTLELM 17 /* left hand side of target list */ + /* element in "retrieve" to C-vars */ +# define mdEXIT 18 /* ## exit */ +# define mdDBS 19 /* ## dbs */ +# define mdTUPRET 20 /* "retrieve" w/o an "into" */ +# define mdFILENAME 21 /* used in "copy" statement */ + + + + + + + +/* define typTYPE xx */ /* c types "Type_spec" */ +# define opINT 1 +# ifndef NO_F4 +# define opFLT 2 +# endif +# define opSTRING 3 +# define opDOUBLE 4 +# define opCHAR 5 +# define opLONG 6 +# define opIDSTRING 7 +# define opSTRUCT 8 + + +/* define typALLOC xx */ /* c var allocation types */ +# define opAUTO 0 +# define opSTATIC 1 +# define opEXTERN 2 +# define opREGISTER 3 diff --git a/WEGA/contrib/ingres/dbs/src/eql/globals.h b/WEGA/contrib/ingres/dbs/src/eql/globals.h new file mode 100644 index 0000000..675bba5 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/eql/globals.h @@ -0,0 +1,165 @@ +/* GLOBALS.H -- EQL declarations */ +/* */ +/* Defines: */ +/* Structures and variables */ +/* used in EQL. */ + +/* Structure declarations */ + + /* parser keyword and operator table node */ +struct optab +{ + char *op_term; /* pointer to terminal */ + int op_token; /* lexical token */ + int op_code; /* code to distinguish different op_terms */ + /* with the same .op_token */ +}; + + + /* C variable tree node */ +struct cvar +{ + char *c_id; /* identifier */ + char c_type; /* type */ + char c_indir; /* indirection level */ + /* (- 1 for strings) */ + struct cvar *c_left; /* < sub-tree */ + struct cvar *c_right; /* > sub-tree */ +}; + + /* Display structures (linked list of strings) */ +struct disp_node +{ + char *d_elm; /* display element */ + struct disp_node *d_next; /* next node */ + int d_line; /* for Symsp nodes, line */ + /* where lexeme was seen */ +}; + +struct display +{ + struct disp_node *disp_first; /* first node in display */ + struct disp_node *disp_last; /* last node in display */ +}; + + /* Retrieval list */ +struct ret_var +{ + char *r_elm; /* string invoking variable */ + /* e.g. "*intpa [2]" */ + struct ret_var *r_next; /* next variable used in "tupret" */ + char r_type; /* type of variable */ +}; + +struct ret_list +{ + struct ret_var *ret_first; /* first node in ret_var chain */ + struct ret_var *ret_last; /* last node in chain */ +}; + + /* "# include" file processing stack (list) */ +struct inc_file +{ + int inc_yyline; /* old file's yyline */ + int inc_lineout; /* " " Lineout */ + char *inc_fid; /* name */ + FILE *inc_infile; /* In_file */ + FILE *inc_outfile; /* Out_file */ + struct inc_file *inc_next; +# ifdef SETBUF + char *inc_ibuf; /* Ibuf */ +# endif +}; + +/* Structure for yacc generated terminal codes */ +/* This avoids having to include functions in */ +/* [grammar.y] for the function to know the */ +/* parser generated token numbers. */ +struct special +{ + int sp_name; /* NAME */ + int sp_sconst; /* SCONST */ + int sp_i2const; /* I2CONST */ + int sp_i4const; /* I4CONST */ + int sp_f8const; /* F8CONST */ + int sp_quote; /* QUOTE */ + int sp_bgncmnt; /* BGNCMNT */ + int sp_endcmnt; /* ENDCMNT */ + int sp_c_code; /* C_CODE */ + int sp_struct_var; +}; + +/* Global definitions */ +extern int Opcode; /* op code to distinguis tokens */ +extern int yychar; /* yacc input token */ +extern int yyline; /* yacc external line counter */ +extern char *yylval; /* yacc external stack variable */ +extern int yydebug; /* set by "-y" command line arg, */ + /* has yacc parser give details */ + /* of parse */ +extern int Newline; /* less than one token has been */ + /* read from the input line, and */ + /* yylex isn't sure yet whether it */ + /* is C_CODE or not */ +extern int Lineout; /* output line count */ +extern int In_quote; /* set if inside an IIwrite("... */ +extern char *Input_file_name; /* input file name */ +extern int C_code_flag; /* set to indicate C-code in parser */ +extern int Pre_proc_flag; /* set to indicate a */ + /* pre-processor line */ +extern int Block_level; /* > 0 local, 0 global */ +extern int Indir_level; /* holds indirection level */ + /* of a reference to a C-var */ +extern int In_string; /* set if output is in a string */ +extern int Fillmode; /* set if output line being filled */ +extern short Fillcnt; /* count to fill a line to */ +extern int Charcnt; /* # chars written onto output line */ +extern int Rtdb; /* set by "-d" command line arg, */ + /* supplies EQL runtime support */ + /* with info to report file name */ + /* and line number in case of an */ + /* error */ +extern int Kwrdnum; /* # of entries in Kwrdtab tokens.y */ +extern char Line_buf[]; /* buffer for input line */ +extern char *Line_pos; /* position in input line */ + +extern struct optab Kwrdtab[]; /* table of key words [tokens.y] */ +extern struct optab Optab[]; /* table of operators [tokens.y] */ +extern struct special Tokens; /* holds yacc generated lex codes */ + /* [tokens.y] */ +extern struct cvar *C_globals; /* Global C-variable tree */ +extern struct cvar *C_locals; /* Local C-variable tree */ +extern struct cvar *F_globals; /* Global structure fields */ +extern struct cvar *F_locals; /* Local structure fields */ +extern struct display *Cv_display; /* display into which "cvarx"'s */ + /* get put */ +extern struct inc_file *Inc_file; /* file stack pushed by #includes */ + +/* I/O manipulation data structures */ +extern FILE *In_file; /* input file */ +extern FILE *Out_file; /* output file */ +# ifdef SETBUF +extern char *Ibuf; /* input buffer */ +extern char Out_buf[]; /* buffer for Out_file */ +# endif + +/* character type mapping */ +# define ASCII_MASK 0177 +# define BYTE_MASK 0377 +extern char Cmap[]; +# ifdef EBCDIC +# ifdef ESER_PSU +extern char _etoa_[]; +# define ETOA(c) _etoa_[(c) & BYTE_MASK] +# endif +# define CMAP(c) Cmap[(ETOA(c)) & ASCII_MASK] +# else +# define CMAP(c) Cmap[(c) & ASCII_MASK] +# endif + +# ifdef xDEBUG +extern char Lex_debug; /* debugging info for lexemes in */ + /* yylex() [yylex.c] */ +extern char Chardebug; /* print debugging info for routine */ + /* in getch.c */ +# endif diff --git a/WEGA/contrib/ingres/dbs/src/eql/main.c b/WEGA/contrib/ingres/dbs/src/eql/main.c new file mode 100644 index 0000000..6220508 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/eql/main.c @@ -0,0 +1,312 @@ +# include +# include "gen.h" +# include "../h/bs.h" +# include "constants.h" +# include "globals.h" +# include "cmap.c" + +# ifdef P8000 +ret_buf AAjmp_buf; +# else +jmp_buf AAjmp_buf; +# endif + +int Opcode; /* op code to distinguis tokens */ +int Newline; /* less than one token has been */ +int Lineout; /* output line count */ +int In_quote; /* set if inside an IIwrite("... */ +char *Input_file_name; /* input file name */ +int C_code_flag; /* set to indicate C-code in parser */ +int Pre_proc_flag; /* set to indicate a */ + /* pre-processor line */ +int Block_level; /* > 0 local, 0 global */ +int Indir_level; /* holds indirection level */ + /* of a reference to a C-var */ +int In_string; /* set if output is in a string */ +int Fillmode; /* set if output line being filled */ +int Charcnt; /* # chars written onto output line */ +int Rtdb; /* set by "-d" command line arg, */ + /* supplies EQL runtime support */ + /* with info to report file name */ + /* and line number in case of an */ + /* error */ +FILE *In_file; /* input file */ +FILE *Out_file; /* output file */ +# ifdef SETBUF +char *Ibuf; /* input buffer */ +char Out_buf[BUFSIZ]; /* buffer for Out_file */ +# endif +struct cvar *C_globals; /* Global C-variable tree */ +struct cvar *C_locals; /* Local C-variable tree */ +struct cvar *F_globals; /* Global structure fields */ +struct cvar *F_locals; /* Local structure fields */ + +# ifdef xDEBUG +char Lex_debug; /* debugging info for lexemes in */ + /* yylex() [yylex.c] */ +char Chardebug; /* print debugging info for routine */ + /* in getch.c */ +# endif + +static int Arg_error; /* set in argproc() [main.c] on */ + /* error in prcessing command line */ + /* arguments. */ + +/* +** MAIN.C -- Start up routines +** +** Usage: +** eql {-d | -v | -c | -y | -f | -f | .q} +** +** Files: +** standard output -- for diagnostics +** .q -- read +** .c -- created and written +** any file appearing in a "#include" with a name +** .q.h -- read +** .c.h -- created and written +** +** Flags: +** possible arguments are: +** -d -- enables run-time errors to have the file name +** and line number where they occurred reported +** Defaults to off. +** -f -- specify the number of characters to fill +** an output line on QL commands +** as being very high (to get C code on the +** right line invariably). +** -f -- fill output lines to integer chars +** (0 is like -f alone) +** Defaults to FILLCNT. +** -y -- have the parser print debugging info +** Defaults to off. +** -v -- (verbose) have the lexical analizer +** print the kind of token it sees. +** (only available if xDEBUG is defined) +** Defaults to off. +** -c -- have every character read or backed up +** echoed (only if xDEBUG is defined) +** Defaults to off. +** -r -- reset all previous flags to default +** .q -- name of a file to be EQL'ed +** +** Defines: +** main() +** argproc() +** eql() +*/ + +char *AApath; + +/* +** MAIN -- invokes the pre-compiler on all the argument files +** +** Parameters: +** argc +** argv +** +*/ +main(argc, argv) +int argc; +char **argv; +{ + extern char **argproc(); + + argv[argc] = 0; + + for (argv++; *argv; ) + { + argv = argproc(argv); + if (!Arg_error) + { + printf("%s :\n", Input_file_name); + eql(Input_file_name); + sync(); + } + } + fflush(stdout); + exit(0); +} + + +/* +** ARGPROC -- process arguments on the command line +** Arguments have effect on all the files following them +** until a "-r" or an argument cancelling the first +** +** Also performs global initializations. +** +** Parameters: +** argv -- a 0 terminated string vector with the +** command lines components. +** +** Returns: +** a new argv with all the leading arguments taken out +** +** Side Effects: +** sets certain variables for certain flags +** -d -- Rtdb +** -c -- Chardebug +** -v -- Lex_debug +** -y -- yydebug +** -f -- Fillcnt +** -r -- resets all variables to default values +** Sets Arg_error on an argument error that should abort +** the pre-processing of the file read. +*/ +char **argproc(argv) +register char **argv; +{ + /* initializations for a new file */ + C_code_flag = Pre_proc_flag = 0; + yyline = Newline = Lineout = 1; + Block_level = Indir_level = In_string = Fillmode = 0; + Charcnt = In_quote = 0; + Arg_error = 0; + + /* free C variable trees, and symbol space */ + freecvar(&C_locals); + freecvar(&F_locals); + freecvar(&C_globals); + freecvar(&F_globals); + + symspfree(); + + for ( ; *argv && **argv == '-'; argv++) + { + switch (*++*argv) + { +# ifdef xDEBUG + case 'V': + case 'v': + Lex_debug = 'v'; + break; + + case 'C': + case 'c': + Chardebug = 'c'; + break; +# endif + + case 'Y': + case 'y': + yydebug = 1; + break; + + case 'D': + case 'd': + Rtdb = 1; + break; + + case 'F': + case 'f': /* line fill */ + if (AA_atoi(++*argv, &Fillcnt)) + printf("bad fill count \"%s\"\n", + *argv); + if (!Fillcnt) + /* make SURE that C_CODE is put + * on line that it was typed in on + */ + Fillcnt = 30000; + break; + + case 'R': + case 'r': /* reset all flags to + * their default values. + */ + yydebug = Rtdb = 0; + Fillcnt = FILLCNT; +# ifdef xDEBUG + Lex_debug = Chardebug = 0; +# endif + break; + + default : + printf("invalid option : '-%c'\n", **argv); + } + } + if (*argv) + Input_file_name = *argv++; + else + { + printf("missing file name after arguments\n"); + Arg_error++; + } + return (argv); +} + + +/* +** EQL -- invokes the precompiler for a non-included file +** +** Parameters: +** filename -- the name of the file to pre-compile +** +** Side Effects: +** performs the preprocessing on +*/ +eql(filename) +register char *filename; +{ + register int l; +# ifdef SETBUF + char in_buf[BUFSIZ]; +# endif + char o_file[100]; + + l = AAlength(filename); + if (l > sizeof o_file - 1) + { + printf("filename \"%s\" too long\n", + filename); + return; + } + if (!AAsequal(".q", &filename[l - 2])) + { + printf("invalid input file name \"%s\"\n", + filename); + return; + } + AAbmove(".c", AAbmove(filename, o_file, l - 2), 3); + Input_file_name = filename; + In_file = Out_file = (FILE *) 0; +# ifdef SETBUF + Ibuf = in_buf; +# endif + + + if (!(In_file = fopen(filename, "r"))) + printf("can't read file \"%s\"\n", filename); + else if (!(Out_file = fopen(o_file, "w"))) + printf("can't write file \"%s\"\n", o_file); + else + { +# ifdef SETBUF + setbuf(In_file, in_buf); + setbuf(Out_file, Out_buf); +# endif + setexit(); + yyparse(); + } + + /* if a reset(3) is done while processing + * an included file, then this closes all + * files skipped. + */ + while (restoref()) + continue; + + if (Out_file) + fclose(Out_file); + if (In_file) + fclose(In_file); + In_file = Out_file = (FILE *) 0; + Input_file_name = 0; + if (Block_level) + printf("unclosed block\n"); +} + + +AAunlall() +{ +}