2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog %W% %G%
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
2003-01-22 14:26:15 +00:00
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2003 *
|
2001-04-09 20:54:03 +01:00
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
2003-01-22 14:26:15 +00:00
|
|
|
* File: yapio.h *
|
|
|
|
* Last rev: 22/1/03 *
|
2001-04-09 20:54:03 +01:00
|
|
|
* mods: *
|
|
|
|
* comments: Input/Output information *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SIMICS
|
|
|
|
#undef HAVE_LIBREADLINE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-11-28 13:17:17 +00:00
|
|
|
#include <wchar.h>
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#ifndef YAP_STDIO
|
|
|
|
|
|
|
|
#define YP_printf printf
|
|
|
|
#define YP_putchar putchar
|
|
|
|
#define YP_getc getc
|
|
|
|
#define YP_fgetc fgetc
|
|
|
|
#define YP_getchar getchar
|
|
|
|
#define YP_fgets fgets
|
|
|
|
#define YP_clearerr clearerr
|
|
|
|
#define YP_feof feof
|
|
|
|
#define YP_ferror ferror
|
2008-03-25 22:03:14 +00:00
|
|
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
2001-06-22 18:53:36 +01:00
|
|
|
#define YP_fileno _fileno
|
|
|
|
#else
|
2001-04-09 20:54:03 +01:00
|
|
|
#define YP_fileno fileno
|
2001-06-22 18:53:36 +01:00
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#define YP_fopen fopen
|
|
|
|
#define YP_fclose fclose
|
|
|
|
#define YP_ftell ftell
|
|
|
|
#define YP_fseek fseek
|
|
|
|
#define YP_setbuf setbuf
|
|
|
|
#define YP_fputs fputs
|
|
|
|
#define YP_ungetc ungetc
|
|
|
|
#define YP_fdopen fdopen
|
|
|
|
#define init_yp_stdio()
|
|
|
|
|
2008-03-25 22:03:14 +00:00
|
|
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
2001-06-22 18:53:36 +01:00
|
|
|
#define open _open
|
|
|
|
#define close _close
|
|
|
|
#define popen _popen
|
|
|
|
#define pclose _pclose
|
|
|
|
#define read _read
|
|
|
|
#define write _write
|
|
|
|
#define isatty _isatty
|
|
|
|
#define putenv(S) _putenv(S)
|
|
|
|
#define chdir(P) _chdir(P)
|
|
|
|
#define getcwd(B,S) _getcwd(B,S)
|
|
|
|
#endif
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#define YP_FILE FILE
|
2002-11-18 18:18:05 +00:00
|
|
|
extern YP_FILE *Yap_stdin;
|
|
|
|
extern YP_FILE *Yap_stdout;
|
|
|
|
extern YP_FILE *Yap_stderr;
|
2001-04-27 17:02:43 +01:00
|
|
|
|
|
|
|
int STD_PROTO(YP_putc,(int, int));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#ifdef putc
|
|
|
|
#undef putc
|
|
|
|
#undef getc
|
|
|
|
#undef putchar
|
|
|
|
#undef getchar
|
|
|
|
#undef stdin
|
|
|
|
#undef stdout
|
|
|
|
#undef stderr
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define printf ERR_printf
|
|
|
|
#define fprintf ERR_fprintf
|
|
|
|
#define putchar ERR_putchar
|
|
|
|
#define putc ERR_putc
|
|
|
|
#define getc ERR_getc
|
|
|
|
#define fgetc ERR_fgetc
|
|
|
|
#define getchar ERR_getchar
|
|
|
|
#define fgets ERR_fgets
|
|
|
|
#define clearerr ERR_clearerr
|
|
|
|
#define feof ERR_feof
|
|
|
|
#define ferror ERR_ferror
|
|
|
|
#define fileno ERR_fileno
|
|
|
|
#define fopen ERR_fopen
|
|
|
|
#define fclose ERR_fclose
|
|
|
|
#define fflush ERR_fflush
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* flags for files in IOSTREAM struct */
|
|
|
|
#define _YP_IO_WRITE 1
|
|
|
|
#define _YP_IO_READ 2
|
|
|
|
|
|
|
|
#define _YP_IO_ERR 0x04
|
|
|
|
#define _YP_IO_EOF 0x08
|
|
|
|
|
|
|
|
#define _YP_IO_FILE 0x10
|
|
|
|
#define _YP_IO_SOCK 0x20
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct IOSTREAM {
|
|
|
|
int check;
|
|
|
|
int fd; /* file descriptor */
|
|
|
|
int flags;
|
|
|
|
int cnt;
|
|
|
|
int buflen;
|
|
|
|
char buf[2];
|
|
|
|
char *ptr;
|
|
|
|
char *base;
|
|
|
|
int (*close)(int fd); /* close file */
|
|
|
|
int (*read)(int fd, char *b, int n); /* read bytes */
|
|
|
|
int (*write)(int fd, char *b, int n);/* write bytes */
|
|
|
|
} YP_FILE;
|
|
|
|
|
|
|
|
#define YP_stdin &yp_iob[0]
|
|
|
|
#define YP_stdout &yp_iob[1]
|
|
|
|
#define YP_stderr &yp_iob[2]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define YP_getc(f) (--(f)->cnt < 0 ? YP_fillbuf(f) : *((unsigned char *) ((f)->ptr++)))
|
|
|
|
#define YP_fgetc(f) YP_fgetc(f)
|
|
|
|
#define YP_putc(c,f) (--(f)->cnt < 0 ? YP_flushbuf(c,f) : (unsigned char) (*(f)->ptr++ = (char) c))
|
|
|
|
#define YP_putchar(cc) YP_putc(cc,YP_stdout)
|
|
|
|
#define YP_getchar() YP_getc(YP_stdin)
|
|
|
|
|
|
|
|
int YP_fillbuf(YP_FILE *f);
|
|
|
|
int YP_flushbuf(int c, YP_FILE *f);
|
|
|
|
|
|
|
|
int YP_printf(char *, ...);
|
|
|
|
int YP_fprintf(YP_FILE *, char *, ...);
|
|
|
|
char* YP_fgets(char *, int, YP_FILE *);
|
|
|
|
char* YP_gets(char *);
|
|
|
|
YP_FILE *YP_fopen(char *, char *);
|
|
|
|
int YP_fclose(YP_FILE *);
|
|
|
|
int YP_fileno(YP_FILE *);
|
|
|
|
int YP_fflush(YP_FILE *);
|
|
|
|
int YP_feof(YP_FILE *);
|
|
|
|
int YP_ftell(YP_FILE *);
|
|
|
|
int YP_fseek(YP_FILE *, int, int);
|
|
|
|
int YP_clearerr(YP_FILE *);
|
|
|
|
void init_yp_stdio(void);
|
|
|
|
int YP_fputs(char *s, YP_FILE *f);
|
|
|
|
int YP_puts(char *s);
|
|
|
|
int YP_setbuf(YP_FILE *f, char *buf);
|
|
|
|
|
|
|
|
|
|
|
|
#define YP_MAX_FILES 40
|
|
|
|
|
|
|
|
extern YP_FILE yp_iob[YP_MAX_FILES];
|
|
|
|
|
|
|
|
#endif /* YAP_STDIO */
|
|
|
|
|
|
|
|
typedef YP_FILE *YP_File;
|
|
|
|
|
2010-04-16 12:11:52 +01:00
|
|
|
typedef enum TokenKinds {
|
2002-11-19 17:10:45 +00:00
|
|
|
Name_tok,
|
|
|
|
Number_tok,
|
|
|
|
Var_tok,
|
|
|
|
String_tok,
|
2006-11-27 17:42:03 +00:00
|
|
|
WString_tok,
|
2002-11-19 17:10:45 +00:00
|
|
|
Ponctuation_tok,
|
|
|
|
Error_tok,
|
|
|
|
eot_tok
|
2010-04-16 12:11:52 +01:00
|
|
|
} tkinds;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
typedef struct TOKEN {
|
2010-04-16 12:11:52 +01:00
|
|
|
enum TokenKinds Tok;
|
2001-04-09 20:54:03 +01:00
|
|
|
Term TokInfo;
|
|
|
|
int TokPos;
|
|
|
|
struct TOKEN *TokNext;
|
|
|
|
} TokEntry;
|
|
|
|
|
2010-04-16 12:11:52 +01:00
|
|
|
#define Ord(X) ((enum TokenKinds) (X))
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#define NextToken GNextToken()
|
|
|
|
|
|
|
|
typedef struct VARSTRUCT {
|
|
|
|
Term VarAdr;
|
|
|
|
CELL hv;
|
|
|
|
struct VARSTRUCT *VarLeft, *VarRight;
|
|
|
|
char VarRep[1];
|
|
|
|
} VarEntry;
|
|
|
|
|
|
|
|
/* Character types for tokenizer and write.c */
|
|
|
|
|
|
|
|
#define UC 1 /* Upper case */
|
|
|
|
#define UL 2 /* Underline */
|
|
|
|
#define LC 3 /* Lower case */
|
|
|
|
#define NU 4 /* digit */
|
|
|
|
#define QT 5 /* single quote */
|
|
|
|
#define DC 6 /* double quote */
|
|
|
|
#define SY 7 /* Symbol character */
|
|
|
|
#define SL 8 /* Solo character */
|
|
|
|
#define BK 9 /* Brackets & friends */
|
|
|
|
#define BS 10 /* Blank */
|
|
|
|
#define EF 11 /* End of File marker */
|
|
|
|
#define CC 12 /* comment char % */
|
|
|
|
|
|
|
|
#define EOFCHAR EOF
|
|
|
|
|
2007-12-29 12:26:41 +00:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#if USE_SOCKET
|
|
|
|
/****************** defines for sockets *********************************/
|
|
|
|
|
|
|
|
typedef enum{ /* in YAP, sockets may be in one of 4 possible status */
|
2002-05-01 17:19:43 +01:00
|
|
|
new_socket,
|
|
|
|
server_socket,
|
|
|
|
client_socket,
|
|
|
|
server_session_socket,
|
|
|
|
closed_socket
|
2001-04-09 20:54:03 +01:00
|
|
|
} socket_info;
|
|
|
|
|
|
|
|
typedef enum{ /* we accept two domains for the moment, IPV6 may follow */
|
|
|
|
af_inet, /* IPV4 */
|
|
|
|
af_unix /* or AF_FILE */
|
|
|
|
} socket_domain;
|
|
|
|
|
2002-11-18 18:18:05 +00:00
|
|
|
Term STD_PROTO(Yap_InitSocketStream,(int, socket_info, socket_domain));
|
2006-08-02 19:18:31 +01:00
|
|
|
int STD_PROTO(Yap_CheckStream,(Term, int, char *));
|
2002-11-18 18:18:05 +00:00
|
|
|
int STD_PROTO(Yap_CheckSocketStream,(Term, char *));
|
|
|
|
socket_domain STD_PROTO(Yap_GetSocketDomain,(int));
|
|
|
|
socket_info STD_PROTO(Yap_GetSocketStatus,(int));
|
|
|
|
void STD_PROTO(Yap_UpdateSocketStream,(int, socket_info, socket_domain));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* routines in ypsocks.c */
|
2002-11-18 18:18:05 +00:00
|
|
|
Int STD_PROTO(Yap_CloseSocket,(int, socket_info, socket_domain));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#endif /* USE_SOCKET */
|
|
|
|
|
2002-02-04 16:12:54 +00:00
|
|
|
/* info on aliases */
|
|
|
|
typedef struct AliasDescS {
|
|
|
|
Atom name;
|
|
|
|
int alias_stream;
|
|
|
|
} * AliasDesc;
|
|
|
|
|
2006-11-27 17:42:03 +00:00
|
|
|
/************ SWI compatible support for different encodings ************/
|
|
|
|
|
2010-04-29 23:04:04 +01:00
|
|
|
#ifndef SIO_NL_POSIX
|
2006-11-27 17:42:03 +00:00
|
|
|
typedef enum {
|
|
|
|
ENC_OCTET = 0,
|
|
|
|
ENC_ISO_LATIN1 = 1,
|
|
|
|
ENC_ISO_ASCII = 2,
|
|
|
|
ENC_ISO_ANSI = 4,
|
|
|
|
ENC_ISO_UTF8 = 8,
|
|
|
|
ENC_UNICODE_BE = 16,
|
2010-10-27 14:49:27 +01:00
|
|
|
ENC_UNICODE_LE = 32,
|
|
|
|
ENC_ISO_UTF32_BE = 64,
|
|
|
|
ENC_ISO_UTF32_LE = 128
|
2006-11-27 17:42:03 +00:00
|
|
|
} encoding_t;
|
2010-04-29 23:04:04 +01:00
|
|
|
#endif
|
2006-11-27 17:42:03 +00:00
|
|
|
|
|
|
|
#define MAX_ISO_LATIN1 255
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/****************** character definition table **************************/
|
2010-05-05 12:45:11 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#define NUMBER_OF_CHARS 256
|
2002-11-18 18:18:05 +00:00
|
|
|
extern char *Yap_chtype;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-05-05 12:45:11 +01:00
|
|
|
EXTERN inline int STD_PROTO(chtype,(Int));
|
|
|
|
int STD_PROTO(Yap_wide_chtype,(Int));
|
2007-12-29 12:26:41 +00:00
|
|
|
|
|
|
|
EXTERN inline int
|
2010-05-05 12:45:11 +01:00
|
|
|
chtype(Int ch)
|
2007-12-29 12:26:41 +00:00
|
|
|
{
|
2010-05-05 12:45:11 +01:00
|
|
|
if (ch < NUMBER_OF_CHARS)
|
2007-12-29 12:26:41 +00:00
|
|
|
return Yap_chtype[ch];
|
2010-05-05 12:45:11 +01:00
|
|
|
return Yap_wide_chtype(ch);
|
2007-12-29 12:26:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* parser stack, used to be AuxSp, now is ASP */
|
2004-10-28 21:12:23 +01:00
|
|
|
#define ParserAuxSp ScannerStack
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* routines in parser.c */
|
2002-11-18 18:18:05 +00:00
|
|
|
VarEntry STD_PROTO(*Yap_LookupVar,(char *));
|
|
|
|
Term STD_PROTO(Yap_VarNames,(VarEntry *,Term));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-01-22 14:26:15 +00:00
|
|
|
/* routines in scanner.c */
|
2008-10-23 22:17:45 +01:00
|
|
|
TokEntry STD_PROTO(*Yap_tokenizer,(int, Term *));
|
2004-02-05 16:57:02 +00:00
|
|
|
void STD_PROTO(Yap_clean_tokenizer,(TokEntry *, VarEntry *, VarEntry *));
|
2007-01-28 14:26:37 +00:00
|
|
|
Term STD_PROTO(Yap_scan_num,(int (*)(int)));
|
2002-11-18 18:18:05 +00:00
|
|
|
char STD_PROTO(*Yap_AllocScannerMemory,(unsigned int));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* routines in iopreds.c */
|
2009-04-22 23:34:08 +01:00
|
|
|
FILE *STD_PROTO(Yap_FileDescriptorFromStream,(Term));
|
2002-11-18 18:18:05 +00:00
|
|
|
Int STD_PROTO(Yap_FirstLineInParse,(void));
|
|
|
|
int STD_PROTO(Yap_CheckIOStream,(Term, char *));
|
2007-11-26 23:43:10 +00:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
|
|
|
void STD_PROTO(Yap_LockStream,(int));
|
|
|
|
void STD_PROTO(Yap_UnLockStream,(int));
|
|
|
|
#else
|
|
|
|
#define Yap_LockStream(X)
|
|
|
|
#define Yap_UnLockStream(X)
|
|
|
|
#endif
|
2010-05-06 15:00:44 +01:00
|
|
|
Int STD_PROTO(Yap_GetStreamFd,(int));
|
2002-11-18 18:18:05 +00:00
|
|
|
void STD_PROTO(Yap_CloseStreams,(int));
|
2008-07-11 18:02:10 +01:00
|
|
|
void STD_PROTO(Yap_FlushStreams,(void));
|
2002-11-18 18:18:05 +00:00
|
|
|
void STD_PROTO(Yap_CloseStream,(int));
|
|
|
|
int STD_PROTO(Yap_PlGetchar,(void));
|
2007-01-28 14:26:37 +00:00
|
|
|
int STD_PROTO(Yap_PlGetWchar,(void));
|
2002-11-18 18:18:05 +00:00
|
|
|
int STD_PROTO(Yap_PlFGetchar,(void));
|
|
|
|
int STD_PROTO(Yap_GetCharForSIGINT,(void));
|
2010-05-06 15:00:44 +01:00
|
|
|
Int STD_PROTO(Yap_StreamToFileNo,(Term));
|
2002-11-18 18:18:05 +00:00
|
|
|
Term STD_PROTO(Yap_OpenStream,(FILE *,char *,Term,int));
|
2004-05-14 17:33:47 +01:00
|
|
|
Term STD_PROTO(Yap_StringToTerm,(char *,Term *));
|
2004-05-14 18:56:47 +01:00
|
|
|
Term STD_PROTO(Yap_TermToString,(Term,char *,unsigned int,int));
|
2004-06-09 04:32:03 +01:00
|
|
|
int STD_PROTO(Yap_GetFreeStreamD,(void));
|
2006-11-27 17:42:03 +00:00
|
|
|
int STD_PROTO(Yap_GetFreeStreamDForReading,(void));
|
|
|
|
|
|
|
|
Term STD_PROTO(Yap_WStringToList,(wchar_t *));
|
|
|
|
Term STD_PROTO(Yap_WStringToListOfAtoms,(wchar_t *));
|
|
|
|
Atom STD_PROTO(Yap_LookupWideAtom,(wchar_t *));
|
2002-11-11 17:38:10 +00:00
|
|
|
|
2001-05-21 21:00:05 +01:00
|
|
|
#define YAP_INPUT_STREAM 0x01
|
|
|
|
#define YAP_OUTPUT_STREAM 0x02
|
|
|
|
#define YAP_APPEND_STREAM 0x04
|
|
|
|
#define YAP_PIPE_STREAM 0x08
|
|
|
|
#define YAP_TTY_STREAM 0x10
|
|
|
|
#define YAP_POPEN_STREAM 0x20
|
|
|
|
#define YAP_BINARY_STREAM 0x40
|
|
|
|
#define YAP_SEEKABLE_STREAM 0x80
|
|
|
|
|
|
|
|
|
2010-12-13 12:38:37 +00:00
|
|
|
#define Quote_illegal_f 0x01
|
|
|
|
#define Ignore_ops_f 0x02
|
|
|
|
#define Handle_vars_f 0x04
|
|
|
|
#define Use_portray_f 0x08
|
|
|
|
#define To_heap_f 0x10
|
|
|
|
#define Unfold_cyclics_f 0x20
|
|
|
|
#define Use_SWI_Stream_f 0x40
|
2002-10-17 01:05:29 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* write.c */
|
2009-05-22 19:24:27 +01:00
|
|
|
void STD_PROTO(Yap_plwrite,(Term,int (*)(int, wchar_t), int, int));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* grow.c */
|
2007-04-18 07:30:41 +01:00
|
|
|
int STD_PROTO(Yap_growheap_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));
|
2002-11-18 18:18:05 +00:00
|
|
|
int STD_PROTO(Yap_growstack_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));
|
2005-01-03 17:06:05 +00:00
|
|
|
int STD_PROTO(Yap_growtrail_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));
|
2002-11-11 17:38:10 +00:00
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef HAVE_ERRNO_H
|
2001-04-09 20:54:03 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#else
|
|
|
|
extern int errno;
|
|
|
|
#endif
|
|
|
|
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef DEBUG
|
2001-04-09 20:54:03 +01:00
|
|
|
#if COROUTINING
|
2002-11-18 18:18:05 +00:00
|
|
|
extern int Yap_Portray_delays;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2005-07-06 16:10:18 +01:00
|
|
|
EXTERN inline UInt STD_PROTO(HashFunction, (unsigned char *));
|
2006-11-27 17:42:03 +00:00
|
|
|
EXTERN inline UInt STD_PROTO(WideHashFunction, (wchar_t *));
|
2003-10-28 01:16:03 +00:00
|
|
|
|
2003-10-06 14:49:38 +01:00
|
|
|
EXTERN inline UInt
|
2005-07-06 16:10:18 +01:00
|
|
|
HashFunction(unsigned char *CHP)
|
2003-10-06 14:49:38 +01:00
|
|
|
{
|
2003-10-28 01:16:03 +00:00
|
|
|
/* djb2 */
|
|
|
|
UInt hash = 5381;
|
|
|
|
UInt c;
|
|
|
|
|
|
|
|
while ((c = *CHP++) != '\0') {
|
|
|
|
/* hash = ((hash << 5) + hash) + c; hash * 33 + c */
|
|
|
|
hash = hash * 33 ^ c;
|
|
|
|
}
|
|
|
|
return hash;
|
|
|
|
/*
|
|
|
|
UInt OUT=0, i = 1;
|
|
|
|
while(*CHP != '\0') { OUT += (UInt)(*CHP++); }
|
2003-10-06 14:49:38 +01:00
|
|
|
return OUT;
|
2003-10-28 01:16:03 +00:00
|
|
|
*/
|
2003-10-06 14:49:38 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2006-11-27 17:42:03 +00:00
|
|
|
EXTERN inline UInt
|
|
|
|
WideHashFunction(wchar_t *CHP)
|
|
|
|
{
|
|
|
|
UInt hash = 5381;
|
|
|
|
UInt c;
|
|
|
|
|
|
|
|
while ((c = *CHP++) != '\0') {
|
|
|
|
hash = hash * 33 ^ c;
|
|
|
|
}
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2002-06-05 02:34:06 +01:00
|
|
|
#define FAIL_ON_PARSER_ERROR 0
|
|
|
|
#define QUIET_ON_PARSER_ERROR 1
|
|
|
|
#define CONTINUE_ON_PARSER_ERROR 2
|
|
|
|
#define EXCEPTION_ON_PARSER_ERROR 3
|
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
#ifdef THREADS
|
|
|
|
#define Yap_IOBotch Yap_thread_gl[worker_id].io_botch
|
|
|
|
#define Yap_tokptr Yap_thread_gl[worker_id].tokptr
|
|
|
|
#define Yap_toktide Yap_thread_gl[worker_id].toktide
|
|
|
|
#define Yap_VarTable Yap_thread_gl[worker_id].var_table
|
|
|
|
#define Yap_AnonVarTable Yap_thread_gl[worker_id].anon_var_table
|
|
|
|
#define Yap_eot_before_eof Yap_thread_gl[worker_id].eot_before_eof
|
|
|
|
#define Yap_FileNameBuf Yap_thread_gl[worker_id].file_name_buf
|
|
|
|
#define Yap_FileNameBuf2 Yap_thread_gl[worker_id].file_name_buf2
|
|
|
|
#else
|
2002-11-18 18:18:05 +00:00
|
|
|
extern jmp_buf Yap_IOBotch;
|
2001-06-22 18:53:36 +01:00
|
|
|
|
2004-01-23 02:23:51 +00:00
|
|
|
/*************** variables concerned with parsing *********************/
|
|
|
|
extern TokEntry *Yap_tokptr, *Yap_toktide;
|
|
|
|
extern VarEntry *Yap_VarTable, *Yap_AnonVarTable;
|
|
|
|
extern int Yap_eot_before_eof;
|
|
|
|
|
|
|
|
extern char Yap_FileNameBuf[YAP_FILENAME_MAX], Yap_FileNameBuf2[YAP_FILENAME_MAX];
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
#ifdef DEBUG
|
2002-11-18 18:18:05 +00:00
|
|
|
extern YP_FILE *Yap_logfile;
|
2002-11-11 17:38:10 +00:00
|
|
|
#endif
|
2001-06-22 18:53:36 +01:00
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
#if USE_SOCKET
|
2002-11-18 18:18:05 +00:00
|
|
|
extern int Yap_sockets_io;
|
2001-08-08 22:17:27 +01:00
|
|
|
#endif
|
2001-09-21 15:22:32 +01:00
|
|
|
|