stdpccts.h

Go to the documentation of this file.
00001 #ifndef STDPCCTS_H
00002 #define STDPCCTS_H
00003 /*
00004  * stdpccts.h -- P C C T S  I n c l u d e
00005  *
00006  * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
00007  * Purdue University Electrical Engineering
00008  * With AHPCRC, University of Minnesota
00009  * ANTLR Version 1.33MR33
00010  */
00011 
00012 #ifndef ANTLR_VERSION
00013 #define ANTLR_VERSION 13333
00014 #endif
00015 
00016 #include "pcctscfg.h"
00017 #include "pccts_stdio.h"
00018 
00019 #include "charbuf.h"
00020 #include "stringbuffer.h"
00021 #include "libicl.h"
00022 #include "libicl_private.h"
00023 #include "glib.h"
00024 #include <stdio.h>
00025 #ifdef _WINDOWS
00026 #include "oaa-windows.h"
00027 #endif
00028 
00029 /* Abstract Syntax Tree fields */
00030 #define AST_FIELDS int isDefined; int type; char* tokenData; size_t tokenLen;
00031 /* Remember column numbers */
00032 #define ZZCOL
00033 /* We define syntax error function */
00034 #define USER_ZZSYN
00035 /* Token buffer size */
00036 /* #define ZZLEXBUFSIZE 10485760*/
00037 #define ZZLEXBUFSIZE 10485760
00038 
00039 extern GByteArray* parser_dblQuoteBuf;
00040 extern char* parser_tmpStrIn;
00041 #ifdef NORMAL_GC
00042 extern void* GC_debug_malloc(size_t, const char*, int);
00043 extern char* gc_strdup(char*);
00044 #endif
00045 
00046 #ifdef NORMAL_GC
00047 #define zzcr_ast(ast, attr, ttype, text) { \
00048   if(((ttype) == ICLDATAQ) || \
00049   ((ttype) == DBLQUOTED)) { \
00050     char* buf = parser_dblQuoteBuf->data; \
00051     g_byte_array_free(parser_dblQuoteBuf, FALSE); \
00052     /* \
00053     char* buf = (char*)malloc(parser_dblQuoteLen + 1); \
00054     memcpy(buf, text, parser_dblQuoteLen); \
00055     buf[parser_dblQuoteLen] = '\0'; \
00056     */ \
00057     ast->tokenData = buf; \
00058     ast->tokenLen = parser_dblQuoteLen; \
00059   } \
00060   else { \
00061     if(zzbufovf) { \
00062       ast->tokenLen = ZZLEXBUFSIZE; \
00063       ast->tokenData = (char*)GC_debug_malloc(ZZLEXBUFSIZE + 1, __FILE__, __LINE__); \
00064       strncpy(ast->tokenData, text, ZZLEXBUFSIZE); \
00065       fprintf(stderr, "ZZLEXBUFSIZE overflowed (%i)\n", ZZLEXBUFSIZE); \
00066     } \
00067     else { \
00068       ast->tokenData = gc_strdup(text); \
00069       ast->tokenLen = strlen(text); \
00070     } \
00071   } \
00072   ast->type = (ttype); \
00073   ast->isDefined = 1; \
00074   ast->right = NULL; \
00075   ast->down = NULL; \
00076   /* printf("zzcr_ast at pointer %p\n", ast); */ \
00077 };
00078 
00079 /*
00080 #define zzd_ast(t) { \
00081   GC_debug_free(t->tokenData); \
00082   fprintf(stderr, "freed token data at pointer %p\n", t); \
00083   t->isDefined = 0; \
00084 } \
00085 */
00086 #undef zzd_ast
00087 
00088 #else
00089 #define zzcr_ast(ast, attr, ttype, text) { \
00090   if(((ttype) == ICLDATAQ) || \
00091   ((ttype) == DBLQUOTED)) { \
00092     char* buf = parser_dblQuoteBuf->data; \
00093     g_byte_array_free(parser_dblQuoteBuf, FALSE); \
00094     /* \
00095     char* buf = (char*)malloc(parser_dblQuoteLen + 1); \
00096     memcpy(buf, text, parser_dblQuoteLen); \
00097     buf[parser_dblQuoteLen] = '\0'; \
00098     */ \
00099     ast->tokenData = buf; \
00100     ast->tokenLen = parser_dblQuoteLen; \
00101   } \
00102   else { \
00103     if(zzbufovf) { \
00104       ast->tokenLen = ZZLEXBUFSIZE; \
00105       ast->tokenData = (char*)malloc(ZZLEXBUFSIZE + 1); \
00106       strncpy(ast->tokenData, text, ZZLEXBUFSIZE); \
00107       fprintf(stderr, "ZZLEXBUFSIZE overflowed (%i)\n", ZZLEXBUFSIZE); \
00108     } \
00109     else { \
00110       ast->tokenData = strdup(text); \
00111       ast->tokenLen = strlen(text); \
00112     } \
00113   } \
00114   ast->type = (ttype); \
00115   ast->isDefined = 1; \
00116   ast->right = NULL; \
00117   ast->down = NULL; \
00118   /* printf("zzcr_ast at pointer %p\n", ast); */ \
00119 };
00120 
00121 /*
00122 #define zzd_ast(t) { \
00123   free(t->tokenData); \
00124   t->isDefined = 0; \
00125 } \
00126 */
00127 #undef zzd_ast
00128 
00129 #endif
00130 
00131 extern int parser_dblQuoteLen;
00132 extern ICLTerm* parser_getTermFromString(char* str, size_t len);
00133 extern ICLTerm* parser_getTermFromStringDebug(char* str, size_t len);
00134 extern int parser_getTermFromBuf(ICLTerm** result, stringbuffer_t* buf, int* lookedAhead);
00135 extern int parser_getNetTermFromBuf(ICLTerm** result, stringbuffer_t* buf);
00136 /*extern void zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text);*/
00137 extern int parser_error;
00138 extern int parser_setDebug(int b);
00139 extern void handleDblQuotedData();
00140 #define LL_K 2
00141 #define GENAST
00142 #define zzSET_SIZE 8
00143 #include "antlr.h"
00144 #include "ast.h"
00145 #include "tokens.h"
00146 #include "dlgdef.h"
00147 #include "mode.h"
00148 #endif

Generated on Wed May 23 17:20:13 2007 using doxygen 1.5.2