📄 scan.c
字号:
/* parser.dlg -- DLG Description of scanner
*
* Generated from: parser.h parser.g
*
* Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
* Purdue University Electrical Engineering
* With AHPCRC, University of Minnesota
* ANTLR Version 1.33MR33
*/
#define ANTLR_VERSION 13333
#include "pcctscfg.h"
#include "pccts_stdio.h"
#include "charbuf.h"
#include "stringbuffer.h"
#include "libicl.h"
#include "libicl_private.h"
#include "glib.h"
#include <stdio.h>
#ifdef _WINDOWS
#include "oaa-windows.h"
#endif
/* Abstract Syntax Tree fields */
#define AST_FIELDS int isDefined; int type; char* tokenData; size_t tokenLen;
/* Remember column numbers */
#define ZZCOL
/* We define syntax error function */
#define USER_ZZSYN
/* Token buffer size */
/* #define ZZLEXBUFSIZE 10485760*/
#define ZZLEXBUFSIZE 10485760
extern GByteArray* parser_dblQuoteBuf;
extern char* parser_tmpStrIn;
#ifdef NORMAL_GC
extern void* GC_debug_malloc(size_t, const char*, int);
extern char* gc_strdup(char*);
#endif
#ifdef NORMAL_GC
#define zzcr_ast(ast, attr, ttype, text) { \
if(((ttype) == ICLDATAQ) || \
((ttype) == DBLQUOTED)) { \
char* buf = parser_dblQuoteBuf->data; \
g_byte_array_free(parser_dblQuoteBuf, FALSE); \
/* \
char* buf = (char*)malloc(parser_dblQuoteLen + 1); \
memcpy(buf, text, parser_dblQuoteLen); \
buf[parser_dblQuoteLen] = '\0'; \
*/ \
ast->tokenData = buf; \
ast->tokenLen = parser_dblQuoteLen; \
} \
else { \
if(zzbufovf) { \
ast->tokenLen = ZZLEXBUFSIZE; \
ast->tokenData = (char*)GC_debug_malloc(ZZLEXBUFSIZE + 1, __FILE__, __LINE__); \
strncpy(ast->tokenData, text, ZZLEXBUFSIZE); \
fprintf(stderr, "ZZLEXBUFSIZE overflowed (%i)\n", ZZLEXBUFSIZE); \
} \
else { \
ast->tokenData = gc_strdup(text); \
ast->tokenLen = strlen(text); \
} \
} \
ast->type = (ttype); \
ast->isDefined = 1; \
ast->right = NULL; \
ast->down = NULL; \
/* printf("zzcr_ast at pointer %p\n", ast); */ \
};
/*
#define zzd_ast(t) { \
GC_debug_free(t->tokenData); \
fprintf(stderr, "freed token data at pointer %p\n", t); \
t->isDefined = 0; \
} \
*/
#undef zzd_ast
#else
#define zzcr_ast(ast, attr, ttype, text) { \
if(((ttype) == ICLDATAQ) || \
((ttype) == DBLQUOTED)) { \
char* buf = parser_dblQuoteBuf->data; \
g_byte_array_free(parser_dblQuoteBuf, FALSE); \
/* \
char* buf = (char*)malloc(parser_dblQuoteLen + 1); \
memcpy(buf, text, parser_dblQuoteLen); \
buf[parser_dblQuoteLen] = '\0'; \
*/ \
ast->tokenData = buf; \
ast->tokenLen = parser_dblQuoteLen; \
} \
else { \
if(zzbufovf) { \
ast->tokenLen = ZZLEXBUFSIZE; \
ast->tokenData = (char*)malloc(ZZLEXBUFSIZE + 1); \
strncpy(ast->tokenData, text, ZZLEXBUFSIZE); \
fprintf(stderr, "ZZLEXBUFSIZE overflowed (%i)\n", ZZLEXBUFSIZE); \
} \
else { \
ast->tokenData = strdup(text); \
ast->tokenLen = strlen(text); \
} \
} \
ast->type = (ttype); \
ast->isDefined = 1; \
ast->right = NULL; \
ast->down = NULL; \
/* printf("zzcr_ast at pointer %p\n", ast); */ \
};
/*
#define zzd_ast(t) { \
free(t->tokenData); \
t->isDefined = 0; \
} \
*/
#undef zzd_ast
#endif
extern int parser_dblQuoteLen;
extern ICLTerm* parser_getTermFromString(char* str, size_t len);
extern ICLTerm* parser_getTermFromStringDebug(char* str, size_t len);
extern int parser_getNetTermFromBuf(ICLTerm** result, stringbuffer_t* buf);
/*extern void zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text);*/
extern int parser_error;
extern int parser_setDebug(int b);
extern void handleDblQuotedData();
#define LL_K 2
#include "antlr.h"
#include "ast.h"
#include "tokens.h"
#include "dlgdef.h"
LOOKAHEAD
void
#ifdef __USE_PROTOS
zzerraction(void)
#else
zzerraction()
#endif
{
(*zzerr)("invalid token");
zzadvance();
zzskip();
}
/*
* D L G tables
*
* Generated from: ../parser.dlg
*
* 1989-2001 by Will Cohen, Terence Parr, and Hank Dietz
* Purdue University Electrical Engineering
* DLG Version 1.33MR33
*/
#include "mode.h"
static void act1()
{
NLA = 1;
}
static void act2()
{
NLA = TERM_LITERAL;
}
static void act3()
{
NLA = ICLDATAQ_LITERAL;
}
static void act4()
{
NLA = LBRACE;
}
static void act5()
{
NLA = RBRACE;
}
static void act6()
{
NLA = LBRACK;
}
static void act7()
{
NLA = RBRACK;
}
static void act8()
{
NLA = LPAREN;
}
static void act9()
{
NLA = RPAREN;
}
static void act10()
{
NLA = DBL_COLON;
}
static void act11()
{
NLA = TURNSTILE;
}
static void act12()
{
NLA = COLON;
}
static void act13()
{
NLA = SEMI;
}
static void act14()
{
NLA = COMMA;
}
static void act15()
{
NLA = PLUS;
}
static void act16()
{
NLA = MINUS;
}
static void act17()
{
NLA = STAR;
}
static void act18()
{
NLA = DIV;
}
static void act19()
{
NLA = EQUAL;
}
static void act20()
{
NLA = BACKSLASH;
}
static void act21()
{
NLA = BANG;
}
static void act22()
{
NLA = TILDE;
}
static void act23()
{
NLA = PIPE;
}
static void act24()
{
NLA = DOT;
}
static void act25()
{
NLA = NUM_INTONE;
}
static void act26()
{
NLA = NUM_INTTWO;
}
static void act27()
{
NLA = NUM_FLOATONE;
}
static void act28()
{
NLA = NUM_FLOATTWO;
}
static void act29()
{
NLA = WS;
zzskip ();
}
static void act30()
{
NLA = NEWLINE;
++zzline; zzskip();
}
static void act31()
{
NLA = SPECIAL_CHAR_LITERAL;
}
static void act32()
{
NLA = IDENT;
}
static void act33()
{
NLA = VARIABLE;
}
static void act34()
{
NLA = 42;
zzmode (STRING_LITERAL_CLASS); zzmore();
}
static void act35()
{
NLA = 43;
parser_dblQuoteLen = 0; zzreplstr(""); zzmode (DBLQUOTED_CLASS); handleDblQuotedData(); zzmore();
}
static unsigned char shift0[257] = {
0, 41, 41, 41, 41, 41, 41, 41, 41, 41,
33, 34, 41, 41, 35, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 33, 26, 40, 36, 36, 41, 36,
39, 15, 16, 22, 21, 20, 18, 29, 23, 31,
30, 30, 30, 30, 30, 30, 30, 30, 30, 17,
19, 36, 24, 36, 36, 36, 38, 38, 38, 38,
32, 38, 38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 13, 25, 14, 36, 38, 36, 9, 37,
6, 8, 2, 37, 37, 37, 5, 37, 37, 7,
4, 37, 37, 37, 10, 3, 37, 1, 37, 37,
37, 37, 37, 37, 11, 28, 12, 27, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 41
};
static void act36()
{
NLA = 1;
}
static void act37()
{
NLA = 44;
zzmore();
}
static void act38()
{
NLA = STRING_LITERAL;
zzmode(START);
}
static void act39()
{
NLA = 46;
++zzline; zzmore();
}
static void act40()
{
NLA = 47;
zzmore();
}
static unsigned char shift1[257] = {
0, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 2, 3, 3, 2, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2
};
#define DfaStates 72
typedef unsigned char DfaState;
static DfaState st0[42] = {
1, 2, 3, 3, 3, 4, 3, 3, 3, 3,
3, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 3, 26, 31,
32, 72
};
static DfaState st1[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st2[42] = {
72, 33, 34, 33, 33, 33, 33, 33, 33, 33,
33, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
33, 33, 33, 72, 72, 72, 72, 33, 33, 72,
72, 72
};
static DfaState st3[42] = {
72, 33, 33, 33, 33, 33, 33, 33, 33, 33,
33, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
33, 33, 33, 72, 72, 72, 72, 33, 33, 72,
72, 72
};
static DfaState st4[42] = {
72, 33, 33, 33, 33, 33, 35, 33, 33, 33,
33, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
33, 33, 33, 72, 72, 72, 72, 33, 33, 72,
72, 72
};
static DfaState st5[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st6[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st7[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st8[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st9[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st10[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st11[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 36, 37, 72,
72, 38, 38, 38, 38, 38, 72, 72, 72, 38,
72, 72, 72, 72, 72, 72, 38, 72, 72, 72,
72, 72
};
static DfaState st12[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 39, 39, 72,
72, 39, 39, 39, 39, 39, 72, 72, 72, 40,
24, 25, 72, 72, 72, 72, 39, 72, 72, 72,
72, 72
};
static DfaState st13[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st14[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72
};
static DfaState st15[42] = {
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 39, 39, 72,
72, 39, 39, 39, 39, 39, 72, 72, 72, 40,
24, 25, 72, 72, 72, 72, 39, 72, 72, 72,
72, 72
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -