-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WardCunningham
authored and
WardCunningham
committed
Dec 20, 2010
1 parent
8d85ee4
commit a470f45
Showing
2 changed files
with
576 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,287 @@ | ||
#ifndef YY_VARIABLE | ||
#define YY_VARIABLE(T) static T | ||
#endif | ||
#ifndef YY_LOCAL | ||
#define YY_LOCAL(T) static T | ||
#endif | ||
#ifndef YY_ACTION | ||
#define YY_ACTION(T) static T | ||
#endif | ||
#ifndef YY_RULE | ||
#define YY_RULE(T) static T | ||
#endif | ||
#ifndef YY_PARSE | ||
#define YY_PARSE(T) T | ||
#endif | ||
#ifndef YYPARSE | ||
#define YYPARSE yyparse | ||
#endif | ||
#ifndef YYPARSEFROM | ||
#define YYPARSEFROM yyparsefrom | ||
#endif | ||
#ifndef YY_INPUT | ||
#define YY_INPUT(buf, result, max_size) \ | ||
{ \ | ||
int yyc= getchar(); \ | ||
result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ | ||
yyprintf((stderr, "<%c>", yyc)); \ | ||
} | ||
#endif | ||
#ifndef YY_BEGIN | ||
#define YY_BEGIN ( mybegin= yybegin= yypos, 1) | ||
#endif | ||
#ifndef YY_END | ||
#define YY_END ( myend= yyend= yypos, 1) | ||
#endif | ||
#ifndef YY_MYBEGIN | ||
#define YY_MYBEGIN ( mybegin= yybegin= yypos, 1) | ||
#endif | ||
#ifndef YY_MYEND | ||
#define YY_MYEND ( myend= yyend= yypos, 1) | ||
#endif | ||
#ifdef YY_DEBUG | ||
# define yyprintf(args) fprintf args | ||
#else | ||
# define yyprintf(args) | ||
#endif | ||
#ifndef YY_DIE | ||
# define YY_DIE(args) fprintf(stderr, args); exit(-1); | ||
#endif | ||
#ifndef YY_OUTPUT | ||
# define YY_OUTPUT(args) | ||
#endif | ||
#ifndef YYSTYPE | ||
#define YYSTYPE int | ||
#endif | ||
#ifndef mytext | ||
#define mytext myText(yythisthunk->mybegin, yythisthunk->myend) | ||
#endif | ||
|
||
#ifndef YY_PART | ||
|
||
typedef void (*yyaction)(char *yytext, int yyleng); | ||
typedef struct _yythunk { int begin, end, mybegin, myend; yyaction action; struct _yythunk *next; } yythunk; | ||
|
||
YY_VARIABLE(char * ) yybuf= 0; | ||
YY_VARIABLE(int ) yybuflen= 0; | ||
YY_VARIABLE(int ) yypos= 0; | ||
YY_VARIABLE(int ) yylimit= 0; | ||
YY_VARIABLE(char * ) yytext= 0; | ||
YY_VARIABLE(int ) yytextlen= 0; | ||
YY_VARIABLE(int ) yybegin= 0; | ||
YY_VARIABLE(int ) yyend= 0; | ||
YY_VARIABLE(int ) yytextmax= 0; | ||
YY_VARIABLE(yythunk *) yythunks= 0; | ||
YY_VARIABLE(int ) yythunkslen= 0; | ||
YY_VARIABLE(int ) yythunkpos= 0; | ||
YY_VARIABLE(yythunk *) yythisthunk= 0; | ||
YY_VARIABLE(char * ) yythisrule= 0; | ||
YY_VARIABLE(YYSTYPE ) yy; | ||
YY_VARIABLE(YYSTYPE *) yyval= 0; | ||
YY_VARIABLE(YYSTYPE *) yyvals= 0; | ||
YY_VARIABLE(int ) yyvalslen= 0; | ||
YY_VARIABLE(long long int) yyaccepted= 0; | ||
|
||
YY_LOCAL(int) yyrefill(void) | ||
{ | ||
int yyn; | ||
while (yybuflen - yypos < 512) | ||
{ | ||
if (yybuflen > 10000000) { | ||
YY_DIE("look ahead exceeds 10MB, giving up.\n"); | ||
} | ||
yybuflen *= 2; | ||
yybuf= realloc(yybuf, yybuflen); | ||
} | ||
YY_INPUT((yybuf + yypos), yyn, (yybuflen - yypos)); | ||
if (!yyn) return 0; | ||
yylimit += yyn; | ||
return 1; | ||
} | ||
|
||
static char* yyunmatched(void) { | ||
static char copy[45]; | ||
int pos = 0; | ||
while (pos < 40) { | ||
if (yypos+pos >= yylimit) break; | ||
char ch = yybuf[yypos+pos]; | ||
if (ch == '\n') { | ||
copy[pos++] = '\\'; | ||
copy[pos++] = 'n'; | ||
break; | ||
} | ||
copy[pos++] = ch; | ||
} | ||
if (yypos+pos < yylimit) { | ||
copy[pos++]='.'; | ||
copy[pos++]='.'; | ||
copy[pos++]='.'; | ||
} | ||
copy[pos] = '\0'; | ||
return copy; | ||
} | ||
|
||
YY_LOCAL(int) yymatchDot(void) | ||
{ | ||
if (yypos >= yylimit && !yyrefill()) return 0; | ||
++yypos; | ||
return 1; | ||
} | ||
|
||
YY_LOCAL(int) yymatchChar(int c) | ||
{ | ||
if (yypos >= yylimit && !yyrefill()) return 0; | ||
if (yybuf[yypos] == c) | ||
{ | ||
++yypos; | ||
yyprintf((stderr, " ok yymatchChar(%c) @ %s\n", c, yyunmatched())); | ||
return 1; | ||
} | ||
yyprintf((stderr, " fail yymatchChar(%c) @ %s\n", c, yyunmatched())); | ||
return 0; | ||
} | ||
|
||
YY_LOCAL(int) yymatchString(char *s) | ||
{ | ||
int yysav= yypos; | ||
while (*s) | ||
{ | ||
if (yypos >= yylimit && !yyrefill()) return 0; | ||
if (yybuf[yypos] != *s) | ||
{ | ||
yypos= yysav; | ||
return 0; | ||
} | ||
++s; | ||
++yypos; | ||
} | ||
return 1; | ||
} | ||
|
||
YY_LOCAL(int) yymatchStringCaseInsensitive(char *s) | ||
{ | ||
int yysav= yypos; | ||
while (*s) | ||
{ | ||
if (yypos >= yylimit && !yyrefill()) return 0; | ||
if (tolower(yybuf[yypos]) != tolower(*s)) | ||
{ | ||
yypos= yysav; | ||
return 0; | ||
} | ||
++s; | ||
++yypos; | ||
} | ||
return 1; | ||
} | ||
|
||
YY_LOCAL(int) yymatchClass(unsigned char *bits) | ||
{ | ||
int c; | ||
if (yypos >= yylimit && !yyrefill()) return 0; | ||
c= yybuf[yypos]; | ||
if (bits[c >> 3] & (1 << (c & 7))) | ||
{ | ||
++yypos; | ||
yyprintf((stderr, " ok yymatchClass @ %s\n", yyunmatched())); | ||
return 1; | ||
} | ||
yyprintf((stderr, " fail yymatchClass @ %s\n", yyunmatched())); | ||
return 0; | ||
} | ||
|
||
YY_LOCAL(void) yyDo(yyaction action, int begin, int end, int mybegin, int myend) | ||
{ | ||
while (yythunkpos >= yythunkslen) | ||
{ | ||
if (yythunkslen > 2000000) { | ||
YY_DIE("thunk storage exceeds 2MB, giving up.\n"); | ||
} | ||
yythunkslen *= 2; | ||
yythunks= realloc(yythunks, sizeof(yythunk) * yythunkslen); | ||
} | ||
yythunks[yythunkpos].begin= begin; | ||
yythunks[yythunkpos].end= end; | ||
yythunks[yythunkpos].mybegin= mybegin; | ||
yythunks[yythunkpos].myend= myend; | ||
yythunks[yythunkpos].action= action; | ||
++yythunkpos; | ||
} | ||
|
||
YY_LOCAL(int) yyText(int begin, int end) | ||
{ | ||
int yyleng= end - begin; | ||
if (yyleng <= 0) | ||
yyleng= 0; | ||
else | ||
{ | ||
while (yytextlen < (yyleng - 1)) | ||
{ | ||
if (yytextlen > 2000000) { | ||
YY_DIE("yytext exceeds 2MB, giving up.\n"); | ||
} | ||
yytextlen *= 2; | ||
yytext= realloc(yytext, yytextlen); | ||
} | ||
memcpy(yytext, yybuf + begin, yyleng); | ||
} | ||
yytext[yyleng]= '\0'; | ||
return yyleng; | ||
} | ||
|
||
YY_LOCAL(char *) myText(int begin, int end) | ||
{ | ||
yyText(begin, end); | ||
return yytext; | ||
} | ||
|
||
YY_LOCAL(void) yyDone(void) | ||
{ | ||
int pos; | ||
for (pos= 0; pos < yythunkpos; ++pos) | ||
{ | ||
yythunk *thunk= &yythunks[pos]; | ||
yythisthunk = thunk; | ||
int yyleng= thunk->end ? yyText(thunk->begin, thunk->end) : thunk->begin; | ||
yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yytext)); | ||
thunk->action(yytext, yyleng); | ||
} | ||
yythunkpos= 0; | ||
} | ||
|
||
YY_LOCAL(void) yyCommit() | ||
{ | ||
YY_OUTPUT((yybuf, yypos)); | ||
if ((yylimit -= yypos)) | ||
{ | ||
memmove(yybuf, yybuf + yypos, yylimit); | ||
} | ||
yybegin -= yypos; | ||
yyend -= yypos; | ||
yyaccepted += yypos; | ||
yypos= yythunkpos= 0; | ||
} | ||
|
||
YY_LOCAL(int) yyAccept(int tp0) | ||
{ | ||
if (tp0) | ||
{ | ||
fprintf(stderr, "accept denied at %d\n", tp0); | ||
return 0; | ||
} | ||
else | ||
{ | ||
yyDone(); | ||
yyCommit(); | ||
} | ||
return 1; | ||
} | ||
|
||
YY_LOCAL(void) yyPush(char *text, int count) { yyval += count; } | ||
YY_LOCAL(void) yyPop(char *text, int count) { yyval -= count; } | ||
YY_LOCAL(void) yySet(char *text, int count) { yyval[count]= yy; } | ||
|
||
#endif /* YY_PART */ | ||
|
||
#define YYACCEPT yyAccept(yythunkpos0) | ||
|
Oops, something went wrong.