This commit is contained in:
Oliver Lehmann 1989-04-03 20:43:02 +00:00
parent e651edd9d8
commit 574f262941
6 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1,62 @@
# include <stdio.h>
# include "gen.h"
# include "constants.h"
# include "globals.h"
/*
** COMMENT.C -- routine to scan comments inside an EQL statement
**
** Uses the endcmnt token code to find the endcmnt
** terminal string, then reads the input until it sees this
** terminal (must be <= 2 characters), returning EOF_TOK and
** giving an error diagnostic if end-of-file is encountered.
**
** Returns:
** CONTINUE -- valid comment
** EOF_TOK -- EOF in comment
**
** Side Effects:
** deletes comments from within an EQL statement
**
*/
comment()
{
register int i;
register int l;
register struct optab *op;
char buf[3];
/* find end of comment operator */
for (op = Optab; op->op_term; op++)
if (op->op_token == Tokens.sp_endcmnt)
break;
if (!op->op_term)
AAsyserr(13000);
/* scan for the end of comment */
l = AAlength(op->op_term);
if (l > sizeof buf - 1)
AAsyserr(13001, l, op->op_term, sizeof buf -1);
/* fill buffer to length of endmnt terminal */
for (i = 0; i < l; i++)
{
if ((buf[i] = getch()) == EOF_TOK)
{
nontermcom :
/* non-terminated comment */
yysemerr("premature EOF encountered in comment", (char *) 0);
return (EOF_TOK);
}
}
/* shift on input until endcmnt */
while (!AAbequal(buf, op->op_term, l))
{
for (i = 0; i < l - 1; i++)
buf[i] = buf[i + 1];
if ((buf[l - 1] = getch()) == EOF_TOK)
goto nontermcom;
}
return (CONTINUE);
}

View File

@ -0,0 +1,46 @@
# include <stdio.h>
# include "gen.h"
# include "../h/dbs.h"
# include "../h/aux.h"
# include "../h/symbol.h"
# include "../h/tree.h"
# include "../h/pipes.h"
# include "IIglobals.h"
/*
** IIflushtup is called to syncronize the data pipe
** after a retrieve.
*/
IIflushtup(file_name, line_no)
register char *file_name;
register int line_no;
{
struct retcode ret;
if (IIproc_name = file_name)
IIline_no = line_no;
# ifdef xETR1
if (IIdebug)
printf("FLUSHTUP: IIerrflag %d\n", IIerrflag);
# endif
if (IIerrflag < 2000)
{
/* flush the data pipe */
IIrdpipe(P_SYNC, &IIeinpipe, IIr_front);
IIrdpipe(P_PRIME, &IIeinpipe);
/* flush the control pipe */
if (IIrdpipe(P_NORM, &IIinpipe, IIr_down, &ret, sizeof (ret)) == sizeof (ret))
{
/* there was a tuple count field */
IItupcnt = ret.rc_tupcount;
}
IIrdpipe(P_SYNC, &IIinpipe, IIr_down);
IIrdpipe(P_PRIME, &IIinpipe);
}
IIin_retrieve = 0;
IIndoms = 0;
IIdoms = 0;
}

View File

@ -0,0 +1,91 @@
# include <stdio.h>
# include "gen.h"
# include "../h/dbs.h"
# include "../h/aux.h"
# include "../h/symbol.h"
# include "../h/tree.h"
# include "../h/pipes.h"
# include "IIglobals.h"
/*
** IIgettup is called to retrieve one instance
** of the target list into the c-variables.
**
** Integers and Floating point numbers can be converted
** to other numbers.
**
** Characters fields must match other character fields.
*/
IIgettup(file_name, line_no)
char *file_name;
int line_no;
{
register int length;
register int domain;
register struct retsym *ret;
char *s;
struct retsym sym;
char temp[MAXFIELD + 1];
extern char *IIitos();
if (IIproc_name = file_name)
IIline_no = line_no;
if (IIerrflag)
return (0); /* error. no data will be coming */
ret = IIretsym;
domain = 0;
for ( ; ; )
{
if (IIrdpipe(P_NORM, &IIeinpipe, IIr_front, &sym, TYP_LEN_SIZ) != TYP_LEN_SIZ)
IIsyserr("GETTUP: READ TYP_LEN");
if (length = ctou(sym.len))
if (IIrdpipe(P_NORM, &IIeinpipe, IIr_front, temp, length) != length)
IIsyserr("GETTUP: READ VALUE len=%d", length);
# ifdef xETR1
if (IIdebug)
printf("GETTUP: typ %d len %d\n", sym.type, length);
# endif
domain++;
switch (sym.type)
{
case INT:
case FLOAT:
if (ret->type == CHAR)
{
s = IIitos(domain);
IIerror(1000, 1, &s);
return (0);
}
if (IIconvert(temp, ret->addr, sym.type, length, ret->type, ctou(ret->len)) < 0)
{
s = IIitos(domain);
IIerror(1001, 1, &s);
}
break;
case CHAR:
if (ret->type != CHAR)
{
s = IIitos(domain);
IIerror(1002, 1, &s);
return (0);
}
IIbmove(temp, ret->addr, length);
ret->addr[length] = '\0'; /* null terminate string */
break;
case EOTUP:
return (1);
case EXIT:
return (0);
}
ret++;
}
}

View File

@ -0,0 +1,66 @@
# include <stdio.h>
# include "gen.h"
# include "../h/dbs.h"
# include "../h/symbol.h"
# include "../h/tree.h"
# include "../h/pipes.h"
# include "IIglobals.h"
/*
** IIN_GET -- Routine to check if there is a next
** tuple coming up the data pipe in a retrieve.
** Loads IIr_sym with the length and type of
** the next domain.
**
** Returns:
** 0 -- on error or end of tuple
** 1 -- otherwise
*/
IIn_get(file_name, line_no)
register char *file_name;
register int line_no;
{
register struct retsym *ret;
if (IIproc_name = file_name)
IIline_no = line_no;
# ifdef xETR1
if (IIdebug)
printf("N_GET: IIdoms %d IIr_sym (typ %d len %d) IIerrflag %d\n",
IIdoms, IIr_sym.type, IIr_sym.len, IIerrflag);
# endif
IIdoms = 0;
/* in case of overflow error, a tuple has been skipped */
if (IIerrflag == 1001)
IIerrflag = 0;
if (IIerrflag)
return (0);
ret = &IIr_sym;
if (ret->type && ret->type != EOTUP)
IIsyserr("N_GET: Unbekannter Typ %d", ret->type);
/* read next type, length pair */
if (IIrdpipe(P_NORM, &IIeinpipe, IIr_front, ret, TYP_LEN_SIZ) != TYP_LEN_SIZ)
IIsyserr("N_GET: READ TYP_LEN");
if (ret->type == EXIT)
return (0);
return (1);
}
/*
** IIERRTEST -- Test if an error occurred within a retrieve.
**
** Returns:
** 1 -- if so
** 0 -- if not
*/
IIerrtest()
{
return (IIerrflag? 1: 0);
}

View File

@ -0,0 +1,22 @@
# include <stdio.h>
# include "gen.h"
# include "../h/dbs.h"
# include "../h/symbol.h"
# include "../h/pipes.h"
# include "IIglobals.h"
/*
** IIsetup is called to mark the start of a retrieve.
*/
IIsetup()
{
# ifdef xETR1
if (IIdebug)
printf("SETUP\n");
# endif
IIin_retrieve = 1;
IIr_sym.type = 0;
IIr_sym.len = 0;
IIdoms = 0;
}

View File

@ -0,0 +1,37 @@
# include <stdio.h>
# include "gen.h"
# include "../h/dbs.h"
# include "../h/symbol.h"
# include "../h/pipes.h"
# include "IIglobals.h"
/*
** IIsync is called to syncronize the running
** of a query with the running of the EQL process.
**
** The query is flushed and an EOP is written
** to the QL parser.
**
** The QL parser will write an end-of-pipe when
** an operation is complete.
*/
IIsync(file_name, line_no)
register char *file_name;
register int line_no;
{
if (IIproc_name = file_name)
IIline_no = line_no;
# ifdef xETR1
if (IIdebug)
printf("SYNC\n");
# endif
IIwrpipe(P_END, &IIoutpipe, IIw_down);
IIwrpipe(P_PRIME, &IIoutpipe, IIw_down);
IIerrflag = 0; /* reset error flag. If an error occures, */
/* IIerrflag will get set in IIerror */
IIrdpipe(P_SYNC, &IIinpipe, IIr_down);
IIrdpipe(P_PRIME, &IIinpipe);
}