Browse code

- save the initial state before transiting to string, this is necessary so that we could parse quoted strings from other states too, such as select.

Jan Janak authored on 27/06/2006 13:45:41
Showing 1 changed files
... ...
@@ -91,7 +91,7 @@
91 91
 
92 92
 
93 93
 	static int comment_nest=0;
94
-	static int state=0;
94
+	static int state=0, old_state=0, old_initial=0;
95 95
 	static struct str_buf s_buf;
96 96
 	int line=1;
97 97
 	int column=1;
... ...
@@ -514,7 +514,6 @@ EAT_ABLE	[\ \t\b\r]
514 514
 <SELECT>{HEXNUMBER}	{ count(); yylval.intval=(int)strtol(yytext, 0, 16); return NUMBER; }
515 515
 <SELECT>{OCTNUMBER}	{ count(); yylval.intval=(int)strtol(yytext, 0, 8); return NUMBER; }
516 516
 <SELECT>{BINNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
517
-<SELECT>.               { unput(yytext[0]); state = INITIAL_S; BEGIN(INITIAL); } /* Rescan the token in INITIAL state */
518 517
 
519 518
 
520 519
 <INITIAL>{ATTR_MARK}    { count(); state = ATTR_S; BEGIN(ATTR); return ATTR_MARK; }
... ...
@@ -579,18 +578,18 @@ EAT_ABLE	[\ \t\b\r]
579 578
 <INITIAL>{CR}		{ count();/* return CR;*/ }
580 579
 
581 580
 
582
-<INITIAL>{QUOTES} { count(); state=STRING_S; BEGIN(STRING1); }
583
-<INITIAL>{TICK} { count(); state=STRING_S; BEGIN(STRING2); }
581
+<INITIAL,SELECT>{QUOTES} { count(); old_initial = YY_START; old_state = state; state=STRING_S; BEGIN(STRING1); }
582
+<INITIAL>{TICK} { count(); old_initial = YY_START; old_state = state; state=STRING_S; BEGIN(STRING2); }
584 583
 
585 584
 
586
-<STRING1>{QUOTES} { count(); state=INITIAL_S; BEGIN(INITIAL);
585
+<STRING1>{QUOTES} { count(); state=old_state; BEGIN(old_initial);
587 586
 						yytext[yyleng-1]=0; yyleng--;
588 587
 						addstr(&s_buf, yytext, yyleng);
589 588
 						yylval.strval=s_buf.s;
590 589
 						memset(&s_buf, 0, sizeof(s_buf));
591 590
 						return STRING;
592 591
 					}
593
-<STRING2>{TICK}  { count(); state=INITIAL_S; BEGIN(INITIAL);
592
+<STRING2>{TICK}  { count(); state=old_state; BEGIN(old_initial);
594 593
 						yytext[yyleng-1]=0; yyleng--;
595 594
 						addstr(&s_buf, yytext, yyleng);
596 595
 						yylval.strval=s_buf.s;
... ...
@@ -632,6 +631,8 @@ EAT_ABLE	[\ \t\b\r]
632 631
 									memset(&s_buf, 0, sizeof(s_buf));
633 632
 									return ID; }
634 633
 
634
+<SELECT>.               { unput(yytext[0]); state = INITIAL_S; BEGIN(INITIAL); } /* Rescan the token in INITIAL state */
635
+
635 636
 
636 637
 <<EOF>>							{
637 638
 									switch(state){