00001 #ifndef lint
00002
00003 static char yyrcsid[] = "$Id: vcc_yacc.cpp,v 1.7 2003/11/04 17:19:02 waspe Exp $";
00004 #endif
00005 #define YYBYACC 1
00006 #define YYMAJOR 1
00007 #define YYMINOR 9
00008 #define yyclearin (yychar=(-1))
00009 #define yyerrok (yyerrflag=0)
00010 #define YYRECOVERING (yyerrflag!=0)
00011 #define yyparse vccparse
00012 #define yylex vcclex
00013 #define yyerror vccerror
00014 #define yychar vccchar
00015 #define yyval vccval
00016 #define yylval vcclval
00017 #define yydebug vccdebug
00018 #define yynerrs vccnerrs
00019 #define yyerrflag vccerrflag
00020 #define yyss vccss
00021 #define yyssp vccssp
00022 #define yyvs vccvs
00023 #define yyvsp vccvsp
00024 #define yylhs vcclhs
00025 #define yylen vcclen
00026 #define yydefred vccdefred
00027 #define yydgoto vccdgoto
00028 #define yysindex vccsindex
00029 #define yyrindex vccrindex
00030 #define yygindex vccgindex
00031 #define yytable vcctable
00032 #define yycheck vcccheck
00033 #define yyname vccname
00034 #define yyrule vccrule
00035 #define YYPREFIX "vcc"
00036 #line 1 "backend/vcc.y"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 #if __DEBUG
00090 #define DBG_(x) printf x
00091 #else
00092 #define DBG_(x)
00093 #endif
00094
00095
00096
00097
00098
00099
00100
00101 #if 0
00102 #define yyparse mime_parse
00103 #define yylex mime_lex
00104 #define yyerror mime_error
00105 #define yychar mime_char
00106
00107 #undef yyval
00108 #define yyval mime_yyval
00109
00110 #undef yylval
00111 #define yylval mime_yylval
00112 #define yydebug mime_debug
00113 #define yynerrs mime_nerrs
00114 #define yyerrflag mime_errflag
00115 #define yyss mime_ss
00116 #define yyssp mime_ssp
00117 #define yyvs mime_vs
00118 #define yyvsp mime_vsp
00119 #define yylhs mime_lhs
00120 #define yylen mime_len
00121 #define yydefred mime_defred
00122 #define yydgoto mime_dgoto
00123 #define yysindex mime_sindex
00124 #define yyrindex mime_rindex
00125 #define yygindex mime_gindex
00126 #define yytable mime_table
00127 #define yycheck mime_check
00128 #define yyname mime_name
00129 #define yyrule mime_rule
00130 #ifdef YYPREFIX
00131 #undef YYPREFIX
00132 #endif
00133 #define YYPREFIX "mime_"
00134 #endif
00135
00136
00137 #ifndef _NO_LINE_FOLDING
00138 #define _SUPPORT_LINE_FOLDING 1
00139 #endif
00140
00141
00142
00143
00144 #if defined(WIN32) || defined(_WIN32)
00145 #ifdef INCLUDEMFC
00146 #include <afx.h>
00147 #endif
00148 #endif
00149
00150 #include <string.h>
00151 #ifndef __MWERKS__
00152 #include <stdlib.h>
00153 #endif
00154 #include <stdio.h>
00155 #include <stdlib.h>
00156 #include <ctype.h>
00157
00158
00159
00160
00161
00162
00163
00164 #include "vobject_p.h"
00165
00166
00167
00168
00169
00170 #define YYDEBUG 0
00171 #define MAXTOKEN 256
00172 #define YYSTACKSIZE 100
00173
00174 #define MAXLEVEL 10
00175
00176
00177
00178
00179 int mime_lineNum, mime_numErrors;
00180 static VObject* vObjList;
00181 static VObject *curProp;
00182 static VObject *curObj;
00183 static VObject* ObjStack[MAXLEVEL];
00184 static int ObjStackTop;
00185
00186
00187
00188 #if __CPLUSPLUS__
00189 extern "C" {
00190 #endif
00191
00192 extern void yyerror(char *s);
00193
00194 #if __CPLUSPLUS__
00195 };
00196 #endif
00197
00198 int yyparse();
00199
00200 enum LexMode {
00201 L_NORMAL,
00202 L_VCARD,
00203 L_VCAL,
00204 L_VEVENT,
00205 L_VTODO,
00206 L_VALUES,
00207 L_BASE64,
00208 L_QUOTED_PRINTABLE
00209 };
00210
00211
00212 static int pushVObject(const char *prop);
00213 static VObject* popVObject();
00214 static void lexPopMode(int top);
00215 static int lexWithinMode(enum LexMode mode);
00216 static void lexPushMode(enum LexMode mode);
00217 static void enterProps(const char *s);
00218 static void enterAttr(const char *s1, const char *s2);
00219 static void enterValues(const char *value);
00220 #define mime_error yyerror
00221 void mime_error(char *s);
00222 void mime_error_(char *s);
00223
00224 #line 189 "backend/vcc.y"
00225 typedef union {
00226 char *str;
00227 VObject *vobj;
00228 } YYSTYPE;
00229 #line 225 "y.tab.c"
00230 #define EQ 257
00231 #define COLON 258
00232 #define DOT 259
00233 #define SEMICOLON 260
00234 #define SPACE 261
00235 #define HTAB 262
00236 #define LINESEP 263
00237 #define NEWLINE 264
00238 #define BEGIN_VCARD 265
00239 #define END_VCARD 266
00240 #define BEGIN_VCAL 267
00241 #define END_VCAL 268
00242 #define BEGIN_VEVENT 269
00243 #define END_VEVENT 270
00244 #define BEGIN_VTODO 271
00245 #define END_VTODO 272
00246 #define ID 273
00247 #define STRING 274
00248 #define YYERRCODE 256
00249 short vcclhs[] = { -1,
00250 0, 6, 6, 5, 5, 8, 3, 9, 3, 7,
00251 7, 13, 10, 10, 15, 11, 11, 14, 14, 16,
00252 17, 17, 1, 18, 12, 12, 2, 2, 20, 4,
00253 21, 4, 19, 19, 22, 22, 22, 25, 23, 26,
00254 23, 27, 24, 28, 24,
00255 };
00256 short vcclen[] = { 2,
00257 1, 2, 1, 1, 1, 0, 4, 0, 3, 2,
00258 1, 0, 5, 1, 0, 3, 1, 2, 1, 2,
00259 1, 3, 1, 0, 4, 1, 1, 0, 0, 4,
00260 0, 3, 2, 1, 1, 1, 1, 0, 4, 0,
00261 3, 0, 4, 0, 3,
00262 };
00263 short vccdefred[] = { 0,
00264 0, 0, 0, 4, 5, 3, 0, 0, 0, 0,
00265 0, 2, 14, 23, 0, 0, 11, 0, 9, 0,
00266 0, 0, 0, 34, 35, 36, 32, 0, 7, 10,
00267 12, 0, 0, 0, 0, 30, 33, 0, 0, 19,
00268 0, 0, 41, 0, 45, 0, 20, 18, 27, 0,
00269 0, 39, 43, 0, 24, 13, 22, 0, 25,
00270 };
00271 short vccdgoto[] = { 3,
00272 15, 50, 4, 5, 6, 7, 22, 8, 9, 17,
00273 18, 51, 41, 39, 28, 40, 47, 58, 23, 10,
00274 11, 24, 25, 26, 32, 33, 34, 35,
00275 };
00276 short vccsindex[] = { -262,
00277 0, 0, 0, 0, 0, 0, -262, -252, -219, -249,
00278 -256, 0, 0, 0, 0, -227, 0, -242, 0, 0,
00279 0, -252, -254, 0, 0, 0, 0, -208, 0, 0,
00280 0, -252, -228, -252, -213, 0, 0, -212, -208, 0,
00281 -214, -233, 0, -224, 0, -195, 0, 0, 0, -197,
00282 -199, 0, 0, -212, 0, 0, 0, -214, 0,
00283 };
00284 short vccrindex[] = { 0,
00285 -222, -238, 0, 0, 0, 0, 65, 0, 0, 0,
00286 0, 0, 0, 0, -215, 0, 0, 0, 0, -220,
00287 -218, -260, 0, 0, 0, 0, 0, 0, 0, 0,
00288 0, 0, 0, 0, 0, 0, 0, 0, -192, 0,
00289 -250, 0, 0, 0, 0, -202, 0, 0, 0, -196,
00290 0, 0, 0, 0, 0, 0, 0, -250, 0,
00291 };
00292 short vccgindex[] = { 0,
00293 3, 0, 0, 0, 61, 0, -7, 0, 0, -16,
00294 0, 11, 0, 0, 0, 31, 0, 0, 0, 0,
00295 0, 48, 0, 0, 0, 0, 0, 0,
00296 };
00297 #define YYTABLESIZE 71
00298 short vcctable[] = { 30,
00299 16, 13, 1, 13, 2, 30, 13, 37, 37, 28,
00300 37, 27, 28, 36, 20, 31, 21, 29, 14, 20,
00301 14, 21, 13, 14, 42, 30, 44, 30, 13, 31,
00302 29, 13, 29, 6, 29, 38, 52, 42, 29, 14,
00303 46, 43, 17, 8, 15, 14, 19, 53, 14, 40,
00304 6, 38, 38, 44, 42, 21, 57, 21, 45, 49,
00305 14, 54, 55, 56, 1, 16, 26, 12, 59, 48,
00306 37,
00307 };
00308 short vcccheck[] = { 16,
00309 8, 256, 265, 256, 267, 22, 256, 268, 269, 260,
00310 271, 268, 263, 268, 269, 258, 271, 256, 273, 269,
00311 273, 271, 256, 273, 32, 42, 34, 44, 256, 268,
00312 269, 256, 271, 256, 273, 256, 270, 256, 266, 273,
00313 38, 270, 258, 266, 260, 273, 266, 272, 273, 270,
00314 273, 260, 273, 272, 273, 258, 54, 260, 272, 274,
00315 273, 257, 260, 263, 0, 258, 263, 7, 58, 39,
00316 23,
00317 };
00318 #define YYFINAL 3
00319 #ifndef YYDEBUG
00320 #define YYDEBUG 0
00321 #endif
00322 #define YYMAXTOKEN 274
00323 #if YYDEBUG
00324 char *vccname[] = {
00325 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00326 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00327 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00328 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00329 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00330 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00331 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"EQ","COLON","DOT","SEMICOLON",
00332 "SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL",
00333 "END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING",
00334 };
00335 char *vccrule[] = {
00336 "$accept : mime",
00337 "mime : vobjects",
00338 "vobjects : vobjects vobject",
00339 "vobjects : vobject",
00340 "vobject : vcard",
00341 "vobject : vcal",
00342 "$$1 :",
00343 "vcard : BEGIN_VCARD $$1 items END_VCARD",
00344 "$$2 :",
00345 "vcard : BEGIN_VCARD $$2 END_VCARD",
00346 "items : items item",
00347 "items : item",
00348 "$$3 :",
00349 "item : prop COLON $$3 values LINESEP",
00350 "item : error",
00351 "$$4 :",
00352 "prop : name $$4 attr_params",
00353 "prop : name",
00354 "attr_params : attr_params attr_param",
00355 "attr_params : attr_param",
00356 "attr_param : SEMICOLON attr",
00357 "attr : name",
00358 "attr : name EQ name",
00359 "name : ID",
00360 "$$5 :",
00361 "values : value SEMICOLON $$5 values",
00362 "values : value",
00363 "value : STRING",
00364 "value :",
00365 "$$6 :",
00366 "vcal : BEGIN_VCAL $$6 calitems END_VCAL",
00367 "$$7 :",
00368 "vcal : BEGIN_VCAL $$7 END_VCAL",
00369 "calitems : calitems calitem",
00370 "calitems : calitem",
00371 "calitem : eventitem",
00372 "calitem : todoitem",
00373 "calitem : items",
00374 "$$8 :",
00375 "eventitem : BEGIN_VEVENT $$8 items END_VEVENT",
00376 "$$9 :",
00377 "eventitem : BEGIN_VEVENT $$9 END_VEVENT",
00378 "$$10 :",
00379 "todoitem : BEGIN_VTODO $$10 items END_VTODO",
00380 "$$11 :",
00381 "todoitem : BEGIN_VTODO $$11 END_VTODO",
00382 };
00383 #endif
00384 #ifdef YYSTACKSIZE
00385 #undef YYMAXDEPTH
00386 #define YYMAXDEPTH YYSTACKSIZE
00387 #else
00388 #ifdef YYMAXDEPTH
00389 #define YYSTACKSIZE YYMAXDEPTH
00390 #else
00391 #define YYSTACKSIZE 500
00392 #define YYMAXDEPTH 500
00393 #endif
00394 #endif
00395 int yydebug;
00396 int yynerrs;
00397 int yyerrflag;
00398 int yychar;
00399 short *yyssp;
00400 YYSTYPE *yyvsp;
00401 YYSTYPE yyval;
00402 YYSTYPE yylval;
00403 short yyss[YYSTACKSIZE];
00404 YYSTYPE yyvs[YYSTACKSIZE];
00405 #define yystacksize YYSTACKSIZE
00406 #line 382 "backend/vcc.y"
00407
00408
00409 static int pushVObject(const char *prop)
00410 {
00411 VObject *newObj;
00412 if (ObjStackTop == MAXLEVEL)
00413 return FALSE;
00414
00415 ObjStack[++ObjStackTop] = curObj;
00416
00417 if (curObj) {
00418 newObj = addProp(curObj,prop);
00419 curObj = newObj;
00420 }
00421 else
00422 curObj = newVObject(prop);
00423
00424 return TRUE;
00425 }
00426
00427
00428
00429
00430 static VObject* popVObject()
00431 {
00432 VObject *oldObj;
00433 if (ObjStackTop < 0) {
00434 yyerror("pop on empty Object Stack\n");
00435 return 0;
00436 }
00437 oldObj = curObj;
00438 curObj = ObjStack[ObjStackTop--];
00439
00440 return oldObj;
00441 }
00442
00443
00444 static void enterValues(const char *value)
00445 {
00446 if (fieldedProp && *fieldedProp) {
00447 if (value) {
00448 addPropValue(curProp,*fieldedProp,value);
00449 }
00450
00451 fieldedProp++;
00452 }
00453 else {
00454 if (value) {
00455 setVObjectStringZValue_(curProp,strdup( value ));
00456 }
00457 }
00458 deleteStr(value);
00459 }
00460
00461 static void enterProps(const char *s)
00462 {
00463 curProp = addGroup(curObj,s);
00464 deleteStr(s);
00465 }
00466
00467 static void enterAttr(const char *s1, const char *s2)
00468 {
00469 const char *p1, *p2=0;
00470 p1 = lookupProp_(s1);
00471 if (s2) {
00472 VObject *a;
00473 p2 = lookupProp_(s2);
00474 a = addProp(curProp,p1);
00475 setVObjectStringZValue(a,p2);
00476 }
00477 else
00478 addProp(curProp,p1);
00479 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0))
00480 lexPushMode(L_BASE64);
00481 else if (qstricmp(p1,VCQuotedPrintableProp) == 0
00482 || (s2 && qstricmp(p2,VCQuotedPrintableProp)==0))
00483 lexPushMode(L_QUOTED_PRINTABLE);
00484 deleteStr(s1); deleteStr(s2);
00485 }
00486
00487
00488 #define MAX_LEX_LOOKAHEAD_0 32
00489 #define MAX_LEX_LOOKAHEAD 64
00490 #define MAX_LEX_MODE_STACK_SIZE 10
00491 #define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
00492
00493 struct LexBuf {
00494
00495 #ifdef INCLUDEMFC
00496 CFile *inputFile;
00497 #else
00498 FILE *inputFile;
00499 #endif
00500 char *inputString;
00501 unsigned long curPos;
00502 unsigned long inputLen;
00503
00504
00505
00506
00507 unsigned long len;
00508 short buf[MAX_LEX_LOOKAHEAD];
00509 unsigned long getPtr;
00510
00511 unsigned long lexModeStackTop;
00512 enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
00513
00514 unsigned long maxToken;
00515 char *strs;
00516 unsigned long strsLen;
00517 } lexBuf;
00518
00519 static void lexPushMode(enum LexMode mode)
00520 {
00521 if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
00522 yyerror("lexical context stack overflow");
00523 else {
00524 lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
00525 }
00526 }
00527
00528 static void lexPopMode(int top)
00529 {
00530
00531
00532 if (top)
00533 lexBuf.lexModeStackTop = 0;
00534 else
00535 if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
00536 }
00537
00538 static int lexWithinMode(enum LexMode mode) {
00539 unsigned long i;
00540 for (i=0;i<lexBuf.lexModeStackTop;i++)
00541 if (mode == lexBuf.lexModeStack[i]) return 1;
00542 return 0;
00543 }
00544
00545 static int lexGetc_()
00546 {
00547
00548 if (lexBuf.curPos == lexBuf.inputLen)
00549 return EOF;
00550 else if (lexBuf.inputString)
00551 return *(lexBuf.inputString + lexBuf.curPos++);
00552 else {
00553 #ifdef INCLUDEMFC
00554 char result;
00555 return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
00556 #else
00557 return fgetc(lexBuf.inputFile);
00558 #endif
00559 }
00560 }
00561
00562 static int lexGeta()
00563 {
00564 ++lexBuf.len;
00565 return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
00566 }
00567
00568 static int lexGeta_(int i)
00569 {
00570 ++lexBuf.len;
00571 return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
00572 }
00573
00574 static void lexSkipLookahead() {
00575 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
00576
00577 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
00578 lexBuf.len--;
00579 }
00580 }
00581
00582 static int lexLookahead() {
00583 int c = (lexBuf.len)?
00584 lexBuf.buf[lexBuf.getPtr]:
00585 lexGeta();
00586
00587 if (c == '\r') {
00588 int a = (lexBuf.len>1)?
00589 lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
00590 lexGeta_(1);
00591 if (a == '\n') {
00592 lexSkipLookahead();
00593 }
00594 lexBuf.buf[lexBuf.getPtr] = c = '\n';
00595 }
00596 else if (c == '\n') {
00597 int a = (lexBuf.len>1)?
00598 lexBuf.buf[lexBuf.getPtr+1]:
00599 lexGeta_(1);
00600 if (a == '\r') {
00601 lexSkipLookahead();
00602 }
00603 lexBuf.buf[lexBuf.getPtr] = '\n';
00604 }
00605 return c;
00606 }
00607
00608 static int lexGetc() {
00609 int c = lexLookahead();
00610 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
00611
00612 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
00613 lexBuf.len--;
00614 }
00615 return c;
00616 }
00617
00618 static void lexSkipLookaheadWord() {
00619 if (lexBuf.strsLen <= lexBuf.len) {
00620 lexBuf.len -= lexBuf.strsLen;
00621 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
00622 }
00623 }
00624
00625 static void lexClearToken()
00626 {
00627 lexBuf.strsLen = 0;
00628 }
00629
00630 static void lexAppendc(int c)
00631 {
00632 lexBuf.strs[lexBuf.strsLen] = c;
00633
00634 if (c == 0) return;
00635 lexBuf.strsLen++;
00636 if (lexBuf.strsLen > lexBuf.maxToken) {
00637
00638 lexBuf.maxToken <<= 1;
00639 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
00640 }
00641 }
00642
00643 static char* lexStr() {
00644 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
00645 }
00646
00647 static void lexSkipWhite() {
00648 int c = lexLookahead();
00649 while (c == ' ' || c == '\t') {
00650 lexSkipLookahead();
00651 c = lexLookahead();
00652 }
00653 }
00654
00655 static char* lexGetWord() {
00656 int c;
00657 lexSkipWhite();
00658 lexClearToken();
00659 c = lexLookahead();
00660 while (c != EOF && !strchr("\t\n ;:=",c)) {
00661 lexAppendc(c);
00662 lexSkipLookahead();
00663 c = lexLookahead();
00664 }
00665 lexAppendc(0);
00666 return lexStr();
00667 }
00668
00669 static void lexPushLookaheadc(int c) {
00670 int putptr;
00671
00672 if (c == EOF) return;
00673 putptr = (int)lexBuf.getPtr - 1;
00674 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
00675 lexBuf.getPtr = putptr;
00676 lexBuf.buf[putptr] = c;
00677 lexBuf.len += 1;
00678 }
00679
00680 static char* lexLookaheadWord() {
00681
00682
00683
00684
00685 int c;
00686 int len = 0;
00687 int curgetptr = 0;
00688 lexSkipWhite();
00689 lexClearToken();
00690 curgetptr = (int)lexBuf.getPtr;
00691 while (len < (MAX_LEX_LOOKAHEAD_0)) {
00692 c = lexGetc();
00693 len++;
00694 if (c == EOF || strchr("\t\n ;:=", c)) {
00695 lexAppendc(0);
00696
00697 lexBuf.len += len;
00698 lexBuf.getPtr = curgetptr;
00699 return lexStr();
00700 }
00701 else
00702 lexAppendc(c);
00703 }
00704 lexBuf.len += len;
00705 lexBuf.getPtr = curgetptr;
00706 return 0;
00707 }
00708
00709 #ifdef _SUPPORT_LINE_FOLDING
00710 static void handleMoreRFC822LineBreak(int c) {
00711
00712
00713
00714
00715
00716 if (c == ';') {
00717 int a;
00718 lexSkipLookahead();
00719
00720 a = lexLookahead();
00721 while (a == ' ' || a == '\t') {
00722 lexSkipLookahead();
00723 a = lexLookahead();
00724 }
00725 if (a == '\n') {
00726 lexSkipLookahead();
00727 a = lexLookahead();
00728 if (a == ' ' || a == '\t') {
00729
00730
00731
00732 lexSkipWhite();
00733 lexPushLookaheadc(';');
00734 }
00735 else {
00736 lexPushLookaheadc('\n');
00737 lexPushLookaheadc(';');
00738 }
00739 }
00740 else {
00741 lexPushLookaheadc(';');
00742 }
00743 }
00744 }
00745
00746 static char* lexGet1Value() {
00747 int c;
00748 lexSkipWhite();
00749 c = lexLookahead();
00750 lexClearToken();
00751 while (c != EOF && (c != ';' || !fieldedProp)) {
00752 if (c == '\\' ) {
00753 int a;
00754 lexSkipLookahead();
00755 a = lexLookahead();
00756 if ( a == ';' ) {
00757 lexAppendc( ';' );
00758 lexSkipLookahead();
00759 } else if ( a == '\n' ) {
00760 lexAppendc( '\n' );
00761 lexSkipLookahead();
00762 } else if ( a == '\\' ) {
00763 lexAppendc( '\\' );
00764 lexSkipLookahead();
00765 } else {
00766 lexAppendc('\\');
00767 }
00768 } else if (c == '\n') {
00769 int a;
00770 lexSkipLookahead();
00771 a = lexLookahead();
00772 if (a == ' ' || a == '\t') {
00773 lexAppendc(' ');
00774 lexSkipLookahead();
00775 }
00776 else {
00777 lexPushLookaheadc('\n');
00778 break;
00779 }
00780 }
00781 else {
00782 lexAppendc(c);
00783 lexSkipLookahead();
00784 }
00785 c = lexLookahead();
00786 }
00787 lexAppendc(0);
00788 handleMoreRFC822LineBreak(c);
00789 return c==EOF?0:lexStr();
00790 }
00791 #endif
00792
00793 static int match_begin_name(int end) {
00794 char *n = lexLookaheadWord();
00795 int token = ID;
00796 if (n) {
00797 if (!qstricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
00798 else if (!qstricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
00799 else if (!qstricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
00800 else if (!qstricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
00801 deleteStr(n);
00802 return token;
00803 }
00804 return 0;
00805 }
00806
00807
00808 #ifdef INCLUDEMFC
00809 void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
00810 #else
00811 void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
00812 #endif
00813 {
00814
00815 lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
00816
00817
00818 lexBuf.inputString = (char*) inputstring;
00819 lexBuf.inputLen = inputlen;
00820 lexBuf.curPos = 0;
00821 lexBuf.inputFile = inputfile;
00822
00823 lexBuf.len = 0;
00824 lexBuf.getPtr = 0;
00825
00826 lexBuf.maxToken = MAXTOKEN;
00827 lexBuf.strs = (char*)malloc(MAXTOKEN);
00828 lexBuf.strsLen = 0;
00829
00830 }
00831
00832 static void finiLex() {
00833 free(lexBuf.strs);
00834 }
00835
00836
00837
00838
00839
00840
00841 static int lexGetDataFromBase64()
00842 {
00843 unsigned long bytesLen = 0, bytesMax = 0;
00844 int quadIx = 0, pad = 0;
00845 unsigned long trip = 0;
00846 unsigned char b;
00847 int c;
00848 unsigned char *bytes = NULL;
00849 unsigned char *oldBytes = NULL;
00850
00851 DBG_(("db: lexGetDataFromBase64\n"));
00852 while (1) {
00853 c = lexGetc();
00854 lexSkipWhite();
00855 if (c == '\n') {
00856 ++mime_lineNum;
00857 if (lexLookahead() == '\n') {
00858
00859 break;
00860 }
00861 else continue;
00862 }
00863 else {
00864 if ((c >= 'A') && (c <= 'Z'))
00865 b = (unsigned char)(c - 'A');
00866 else if ((c >= 'a') && (c <= 'z'))
00867 b = (unsigned char)(c - 'a') + 26;
00868 else if ((c >= '0') && (c <= '9'))
00869 b = (unsigned char)(c - '0') + 52;
00870 else if (c == '+')
00871 b = 62;
00872 else if (c == '/')
00873 b = 63;
00874 else if (c == '=') {
00875 b = 0;
00876 pad++;
00877 } else {
00878 if (bytes) free(bytes);
00879 else if (oldBytes) free(oldBytes);
00880
00881 DBG_(("db: invalid character 0x%x '%c'\n", c,c));
00882 if (c != EOF) {
00883 c = lexGetc();
00884 while (c != EOF) {
00885 if (c == '\n') {
00886 lexSkipWhite();
00887 if(lexLookahead() == '\n') {
00888 ++mime_lineNum;
00889 break;
00890 }
00891 }
00892 c = lexGetc();
00893 }
00894 }
00895 return c != EOF;
00896 }
00897 trip = (trip << 6) | b;
00898 if (++quadIx == 4) {
00899 unsigned char outBytes[3];
00900 int numOut;
00901 int i;
00902 for (i = 0; i < 3; i++) {
00903 outBytes[2-i] = (unsigned char)(trip & 0xFF);
00904 trip >>= 8;
00905 }
00906 numOut = 3 - pad;
00907 if (bytesLen + numOut > bytesMax) {
00908 if (!bytes) {
00909 bytesMax = 1024;
00910 bytes = (unsigned char*)malloc((size_t)bytesMax);
00911 }
00912 else {
00913 bytesMax <<= 2;
00914 oldBytes = bytes;
00915 bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
00916 }
00917 if (bytes == 0) {
00918 mime_error("out of memory while processing BASE64 data\n");
00919 }
00920 }
00921 if (bytes) {
00922 memcpy(bytes + bytesLen, outBytes, numOut);
00923 bytesLen += numOut;
00924 }
00925 trip = 0;
00926 quadIx = 0;
00927 }
00928 }
00929 }
00930 DBG_(("db: bytesLen = %d\n", bytesLen));
00931
00932
00933 if (bytes) {
00934 setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
00935 free(bytes);
00936 }
00937 else if (oldBytes) {
00938 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
00939 free(oldBytes);
00940 }
00941 return bytesLen;
00942 }
00943
00944 static int match_begin_end_name(int end) {
00945 int token;
00946 lexSkipWhite();
00947 if (lexLookahead() != ':') return ID;
00948 lexSkipLookahead();
00949 lexSkipWhite();
00950 token = match_begin_name(end);
00951 if (token == ID) {
00952 lexPushLookaheadc(':');
00953 DBG_(("db: ID '%s'\n", yylval.str));
00954 return ID;
00955 }
00956 else if (token != 0) {
00957 lexSkipLookaheadWord();
00958 deleteStr(yylval.str);
00959 DBG_(("db: begin/end %d\n", token));
00960 return token;
00961 }
00962 return 0;
00963 }
00964
00965 static char* lexGetQuotedPrintable()
00966 {
00967 int c;
00968 lexSkipWhite();
00969 c = lexLookahead();
00970 lexClearToken();
00971
00972 while (c != EOF && (c != ';' || !fieldedProp)) {
00973 if (c == '\n') {
00974
00975 break;
00976 } else if (c == '=') {
00977 int cur = 0;
00978 int next;
00979
00980 lexSkipLookahead();
00981 next = lexLookahead();
00982
00983 if (next == '\n') {
00984
00985 lexSkipLookahead();
00986 c = lexLookahead();
00987 ++mime_lineNum;
00988 continue;
00989 } else if (next >= '0' && next <= '9') {
00990 cur = next - '0';
00991 } else if (next >= 'A' && next <= 'F') {
00992 cur = next - 'A' + 10;
00993 } else {
00994
00995
00996
00997 lexSkipLookahead();
00998 c = lexLookahead();
00999 continue;
01000 }
01001
01002 lexSkipLookahead();
01003 next = lexLookahead();
01004
01005 cur = cur * 16;
01006
01007 if (next >= '0' && next <= '9') {
01008 cur += next - '0';
01009 } else if (next >= 'A' && next <= 'F') {
01010 cur += next - 'A' + 10;
01011 } else {
01012
01013
01014
01015 lexSkipLookahead();
01016 c = lexLookahead();
01017 continue;
01018 }
01019
01020
01021 lexSkipLookahead();
01022 lexAppendc(cur);
01023 } else {
01024 lexSkipLookahead();
01025 lexAppendc(c);
01026 }
01027 c = lexLookahead();
01028 }
01029 lexAppendc(0);
01030 return c==EOF?0:lexStr();
01031 }
01032
01033 static int yylex() {
01034
01035 int lexmode = LEXMODE();
01036 if (lexmode == L_VALUES) {
01037 int c = lexGetc();
01038 if (c == ';' && fieldedProp) {
01039 DBG_(("db: SEMICOLON\n"));
01040 lexPushLookaheadc(c);
01041 handleMoreRFC822LineBreak(c);
01042 lexSkipLookahead();
01043 return SEMICOLON;
01044 }
01045 else if (strchr("\n",c)) {
01046 ++mime_lineNum;
01047
01048 c = lexLookahead();
01049 while (strchr("\n",c)) {
01050 lexSkipLookahead();
01051 c = lexLookahead();
01052 ++mime_lineNum;
01053 }
01054 DBG_(("db: LINESEP\n"));
01055 return LINESEP;
01056 }
01057 else {
01058 char *p = 0;
01059 lexPushLookaheadc(c);
01060 if (lexWithinMode(L_BASE64)) {
01061
01062 yylval.str = NULL;
01063 return lexGetDataFromBase64() ? STRING : 0;
01064 }
01065 else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
01066 p = lexGetQuotedPrintable();
01067 }
01068 else {
01069 #ifdef _SUPPORT_LINE_FOLDING
01070 p = lexGet1Value();
01071 #else
01072 p = lexGetStrUntil(";\n");
01073 #endif
01074 }
01075 if (p) {
01076 DBG_(("db: STRING: '%s'\n", p));
01077 yylval.str = p;
01078 return STRING;
01079 }
01080 else return 0;
01081 }
01082 }
01083 else {
01084
01085 while (1) {
01086 int c = lexGetc();
01087 switch(c) {
01088 case ':': {
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099 DBG_(("db: COLON\n"));
01100 return COLON;
01101 }
01102 case ';':
01103 DBG_(("db: SEMICOLON\n"));
01104 return SEMICOLON;
01105 case '=':
01106 DBG_(("db: EQ\n"));
01107 return EQ;
01108
01109 case '\t':
01110 case ' ': continue;
01111 case '\n': {
01112 ++mime_lineNum;
01113 continue;
01114 }
01115 case EOF: return 0;
01116 break;
01117 default: {
01118 lexPushLookaheadc(c);
01119 if (isalnum(c)) {
01120 char *t = lexGetWord();
01121 yylval.str = t;
01122 if (!qstricmp(t, "begin")) {
01123 return match_begin_end_name(0);
01124 }
01125 else if (!qstricmp(t,"end")) {
01126 return match_begin_end_name(1);
01127 }
01128 else {
01129 DBG_(("db: ID '%s'\n", t));
01130 return ID;
01131 }
01132 }
01133 else {
01134
01135 return 0;
01136 }
01137 break;
01138 }
01139 }
01140 }
01141 }
01142 return 0;
01143 }
01144
01145
01146
01147
01148
01149
01150 static VObject* Parse_MIMEHelper()
01151 {
01152 ObjStackTop = -1;
01153 mime_numErrors = 0;
01154 mime_lineNum = 1;
01155 vObjList = 0;
01156 curObj = 0;
01157
01158 if (yyparse() != 0)
01159 return 0;
01160
01161 finiLex();
01162 return vObjList;
01163 }
01164
01165
01166 DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
01167 {
01168 initLex(input, len, 0);
01169 return Parse_MIMEHelper();
01170 }
01171
01172
01173 #if INCLUDEMFC
01174
01175 DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
01176 {
01177 unsigned long startPos;
01178 VObject *result;
01179
01180 initLex(0,-1,file);
01181 startPos = file->GetPosition();
01182 if (!(result = Parse_MIMEHelper()))
01183 file->Seek(startPos, CFile::begin);
01184 return result;
01185 }
01186
01187 #else
01188
01189 VObject* Parse_MIME_FromFile(FILE *file)
01190 {
01191 VObject *result;
01192 long startPos;
01193
01194 initLex(0,(unsigned long)-1,file);
01195 startPos = ftell(file);
01196 if (!(result = Parse_MIMEHelper())) {
01197 fseek(file,startPos,SEEK_SET);
01198 }
01199 return result;
01200 }
01201
01202 DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
01203 {
01204 FILE *fp = fopen(fname,"r");
01205 if (fp) {
01206 VObject* o = Parse_MIME_FromFile(fp);
01207 fclose(fp);
01208 return o;
01209 }
01210 else {
01211 char msg[80];
01212 sprintf(msg, "can't open file '%s' for reading\n", fname);
01213 mime_error_(msg);
01214 return 0;
01215 }
01216 }
01217
01218 #endif
01219
01220
01221
01222 static MimeErrorHandler mimeErrorHandler;
01223
01224 DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
01225 {
01226 mimeErrorHandler = me;
01227 }
01228
01229 void mime_error(char *s)
01230 {
01231 char msg[256];
01232 if (mimeErrorHandler) {
01233 sprintf(msg,"%s at line %d", s, mime_lineNum);
01234 mimeErrorHandler(msg);
01235 }
01236 }
01237
01238 void mime_error_(char *s)
01239 {
01240 if (mimeErrorHandler) {
01241 mimeErrorHandler(s);
01242 }
01243 }
01244
01245 #line 1241 "y.tab.c"
01246 #define YYABORT goto yyabort
01247 #define YYREJECT goto yyabort
01248 #define YYACCEPT goto yyaccept
01249 #define YYERROR goto yyerrlab
01250 int
01251 #if defined(__STDC__)
01252 yyparse(void)
01253 #else
01254 yyparse()
01255 #endif
01256 {
01257 register int yym, yyn, yystate;
01258 #if YYDEBUG
01259 register char *yys;
01260 extern char *getenv();
01261
01262 if (yys = getenv("YYDEBUG"))
01263 {
01264 yyn = *yys;
01265 if (yyn >= '0' && yyn <= '9')
01266 yydebug = yyn - '0';
01267 }
01268 #endif
01269
01270 yynerrs = 0;
01271 yyerrflag = 0;
01272 yychar = (-1);
01273
01274 yyssp = yyss;
01275 yyvsp = yyvs;
01276 *yyssp = yystate = 0;
01277
01278 yyloop:
01279 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
01280 if (yychar < 0)
01281 {
01282 if ((yychar = yylex()) < 0) yychar = 0;
01283 #if YYDEBUG
01284 if (yydebug)
01285 {
01286 yys = 0;
01287 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
01288 if (!yys) yys = "illegal-symbol";
01289 printf("%sdebug: state %d, reading %d (%s)\n",
01290 YYPREFIX, yystate, yychar, yys);
01291 }
01292 #endif
01293 }
01294 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
01295 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
01296 {
01297 #if YYDEBUG
01298 if (yydebug)
01299 printf("%sdebug: state %d, shifting to state %d\n",
01300 YYPREFIX, yystate, yytable[yyn]);
01301 #endif
01302 if (yyssp >= yyss + yystacksize - 1)
01303 {
01304 goto yyoverflow;
01305 }
01306 *++yyssp = yystate = yytable[yyn];
01307 *++yyvsp = yylval;
01308 yychar = (-1);
01309 if (yyerrflag > 0) --yyerrflag;
01310 goto yyloop;
01311 }
01312 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
01313 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
01314 {
01315 yyn = yytable[yyn];
01316 goto yyreduce;
01317 }
01318 if (yyerrflag) goto yyinrecovery;
01319 yyerror("syntax error");
01320 #ifdef lint
01321 goto yyerrlab;
01322 #endif
01323 yyerrlab:
01324 ++yynerrs;
01325 yyinrecovery:
01326 if (yyerrflag < 3)
01327 {
01328 yyerrflag = 3;
01329 for (;;)
01330 {
01331 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
01332 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
01333 {
01334 #if YYDEBUG
01335 if (yydebug)
01336 printf("%sdebug: state %d, error recovery shifting\
01337 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
01338 #endif
01339 if (yyssp >= yyss + yystacksize - 1)
01340 {
01341 goto yyoverflow;
01342 }
01343 *++yyssp = yystate = yytable[yyn];
01344 *++yyvsp = yylval;
01345 goto yyloop;
01346 }
01347 else
01348 {
01349 #if YYDEBUG
01350 if (yydebug)
01351 printf("%sdebug: error recovery discarding state %d\n",
01352 YYPREFIX, *yyssp);
01353 #endif
01354 if (yyssp <= yyss) goto yyabort;
01355 --yyssp;
01356 --yyvsp;
01357 }
01358 }
01359 }
01360 else
01361 {
01362 if (yychar == 0) goto yyabort;
01363 #if YYDEBUG
01364 if (yydebug)
01365 {
01366 yys = 0;
01367 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
01368 if (!yys) yys = "illegal-symbol";
01369 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
01370 YYPREFIX, yystate, yychar, yys);
01371 }
01372 #endif
01373 yychar = (-1);
01374 goto yyloop;
01375 }
01376 yyreduce:
01377 #if YYDEBUG
01378 if (yydebug)
01379 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
01380 YYPREFIX, yystate, yyn, yyrule[yyn]);
01381 #endif
01382 yym = yylen[yyn];
01383 yyval = yyvsp[1-yym];
01384 switch (yyn)
01385 {
01386 case 2:
01387 #line 221 "backend/vcc.y"
01388 { addList(&vObjList, yyvsp[0].vobj); curObj = 0; }
01389 break;
01390 case 3:
01391 #line 223 "backend/vcc.y"
01392 { addList(&vObjList, yyvsp[0].vobj); curObj = 0; }
01393 break;
01394 case 6:
01395 #line 232 "backend/vcc.y"
01396 {
01397 lexPushMode(L_VCARD);
01398 if (!pushVObject(VCCardProp)) YYERROR;
01399 }
01400 break;
01401 case 7:
01402 #line 237 "backend/vcc.y"
01403 {
01404 lexPopMode(0);
01405 yyval.vobj = popVObject();
01406 }
01407 break;
01408 case 8:
01409 #line 242 "backend/vcc.y"
01410 {
01411 lexPushMode(L_VCARD);
01412 if (!pushVObject(VCCardProp)) YYERROR;
01413 }
01414 break;
01415 case 9:
01416 #line 247 "backend/vcc.y"
01417 {
01418 lexPopMode(0);
01419 yyval.vobj = popVObject();
01420 }
01421 break;
01422 case 12:
01423 #line 258 "backend/vcc.y"
01424 {
01425 lexPushMode(L_VALUES);
01426 }
01427 break;
01428 case 13:
01429 #line 262 "backend/vcc.y"
01430 {
01431 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
01432 lexPopMode(0);
01433 lexPopMode(0);
01434 }
01435 break;
01436 case 15:
01437 #line 271 "backend/vcc.y"
01438 {
01439 enterProps(yyvsp[0].str);
01440 }
01441 break;
01442 case 17:
01443 #line 276 "backend/vcc.y"
01444 {
01445 enterProps(yyvsp[0].str);
01446 }
01447 break;
01448 case 21:
01449 #line 289 "backend/vcc.y"
01450 {
01451 enterAttr(yyvsp[0].str,0);
01452 }
01453 break;
01454 case 22:
01455 #line 293 "backend/vcc.y"
01456 {
01457 enterAttr(yyvsp[-2].str,yyvsp[0].str);
01458
01459 }
01460 break;
01461 case 24:
01462 #line 302 "backend/vcc.y"
01463 { enterValues(yyvsp[-1].str); }
01464 break;
01465 case 26:
01466 #line 304 "backend/vcc.y"
01467 { enterValues(yyvsp[0].str); }
01468 break;
01469 case 28:
01470 #line 309 "backend/vcc.y"
01471 { yyval.str = 0; }
01472 break;
01473 case 29:
01474 #line 314 "backend/vcc.y"
01475 { if (!pushVObject(VCCalProp)) YYERROR; }
01476 break;
01477 case 30:
01478 #line 317 "backend/vcc.y"
01479 { yyval.vobj = popVObject(); }
01480 break;
01481 case 31:
01482 #line 319 "backend/vcc.y"
01483 { if (!pushVObject(VCCalProp)) YYERROR; }
01484 break;
01485 case 32:
01486 #line 321 "backend/vcc.y"
01487 { yyval.vobj = popVObject(); }
01488 break;
01489 case 38:
01490 #line 336 "backend/vcc.y"
01491 {
01492 lexPushMode(L_VEVENT);
01493 if (!pushVObject(VCEventProp)) YYERROR;
01494 }
01495 break;
01496 case 39:
01497 #line 342 "backend/vcc.y"
01498 {
01499 lexPopMode(0);
01500 popVObject();
01501 }
01502 break;
01503 case 40:
01504 #line 347 "backend/vcc.y"
01505 {
01506 lexPushMode(L_VEVENT);
01507 if (!pushVObject(VCEventProp)) YYERROR;
01508 }
01509 break;
01510 case 41:
01511 #line 352 "backend/vcc.y"
01512 {
01513 lexPopMode(0);
01514 popVObject();
01515 }
01516 break;
01517 case 42:
01518 #line 360 "backend/vcc.y"
01519 {
01520 lexPushMode(L_VTODO);
01521 if (!pushVObject(VCTodoProp)) YYERROR;
01522 }
01523 break;
01524 case 43:
01525 #line 366 "backend/vcc.y"
01526 {
01527 lexPopMode(0);
01528 popVObject();
01529 }
01530 break;
01531 case 44:
01532 #line 371 "backend/vcc.y"
01533 {
01534 lexPushMode(L_VTODO);
01535 if (!pushVObject(VCTodoProp)) YYERROR;
01536 }
01537 break;
01538 case 45:
01539 #line 376 "backend/vcc.y"
01540 {
01541 lexPopMode(0);
01542 popVObject();
01543 }
01544 break;
01545 #line 1541 "y.tab.c"
01546 }
01547 yyssp -= yym;
01548 yystate = *yyssp;
01549 yyvsp -= yym;
01550 yym = yylhs[yyn];
01551 if (yystate == 0 && yym == 0)
01552 {
01553 #if YYDEBUG
01554 if (yydebug)
01555 printf("%sdebug: after reduction, shifting from state 0 to\
01556 state %d\n", YYPREFIX, YYFINAL);
01557 #endif
01558 yystate = YYFINAL;
01559 *++yyssp = YYFINAL;
01560 *++yyvsp = yyval;
01561 if (yychar < 0)
01562 {
01563 if ((yychar = yylex()) < 0) yychar = 0;
01564 #if YYDEBUG
01565 if (yydebug)
01566 {
01567 yys = 0;
01568 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
01569 if (!yys) yys = "illegal-symbol";
01570 printf("%sdebug: state %d, reading %d (%s)\n",
01571 YYPREFIX, YYFINAL, yychar, yys);
01572 }
01573 #endif
01574 }
01575 if (yychar == 0) goto yyaccept;
01576 goto yyloop;
01577 }
01578 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
01579 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
01580 yystate = yytable[yyn];
01581 else
01582 yystate = yydgoto[yym];
01583 #if YYDEBUG
01584 if (yydebug)
01585 printf("%sdebug: after reduction, shifting from state %d \
01586 to state %d\n", YYPREFIX, *yyssp, yystate);
01587 #endif
01588 if (yyssp >= yyss + yystacksize - 1)
01589 {
01590 goto yyoverflow;
01591 }
01592 *++yyssp = yystate;
01593 *++yyvsp = yyval;
01594 goto yyloop;
01595 yyoverflow:
01596 yyerror("yacc stack overflow");
01597 yyabort:
01598 return (1);
01599 yyaccept:
01600 return (0);
01601 }