blob: f49ea237c5d412742bd0a5280e480e853aff8627 (
plain)
1
2
3
4
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
31
32
33
|
/*
* yymore.lex: An example of using yymore()
* to good effect.
*/
%{
#include <memory.h>
void yyerror(char *message)
{
printf("Error: %s\n",message);
}
%}
%x STRING
%%
\" BEGIN(STRING);
<STRING>[^\\\n"]* yymore();
<STRING><<EOF>> yyerror("EOF in string."); BEGIN(INITIAL);
<STRING>\n yyerror("Unterminated string."); BEGIN(INITIAL);
<STRING>\\\n {
bcopy(yytext,yytext+2,yyleng-2);
yytext += 2; yyleng -= 2;
yymore();
}
<STRING>\" {
yyleng -= 1; yytext[yyleng] = '\0';
printf("string = \"%s\"",yytext); BEGIN(INITIAL);
}
%%
|