1 /* 2 * yymore.lex: An example of using yymore() 3 * to good effect. 4 */ 5 6 %{ 7 #include <memory.h> 8 yyerror(char * message)9void yyerror(char *message) 10 { 11 printf("Error: %s\n",message); 12 } 13 14 %} 15 16 %x STRING 17 18 %% 19 \" BEGIN(STRING); 20 21 <STRING>[^\\\n"]* yymore(); 22 <STRING><<EOF>> yyerror("EOF in string."); BEGIN(INITIAL); 23 <STRING>\n yyerror("Unterminated string."); BEGIN(INITIAL); 24 <STRING>\\\n yymore(); 25 <STRING>\" { 26 yytext[yyleng-1] = '\0'; 27 printf("string = \"%s\"",yytext); BEGIN(INITIAL); 28 } 29 %% 30