]>
Commit | Line | Data |
---|---|---|
ffc11f03 CP |
1 | %option noyywrap |
2 | ||
3 | %{ | |
e828314e | 4 | #include "../lib/sstring.h" |
ffc11f03 | 5 | |
e828314e | 6 | #define YYSTYPE sstring * |
ffc11f03 CP |
7 | extern YYSTYPE yylval; |
8 | ||
e828314e CP |
9 | #include "y.tab.h" |
10 | ||
ffc11f03 CP |
11 | #include <stdlib.h> |
12 | #include "../lib/stringbuf.h" | |
13 | ||
14 | #define MAX_STR_CONST 512 | |
e828314e | 15 | |
ffc11f03 CP |
16 | %} |
17 | ||
18 | digit [0-9] | |
19 | letter [a-zA-Z] | |
20 | ||
21 | %x str | |
22 | %% | |
23 | ||
24 | char bufdata[MAX_STR_CONST]; | |
25 | StringBuf buf; | |
26 | ||
27 | \" { | |
28 | sbinit(&buf, bufdata, sizeof(bufdata)); | |
29 | BEGIN(str); | |
30 | } | |
31 | ||
32 | <str>{ | |
33 | \" { | |
34 | BEGIN(INITIAL); | |
35 | sbterminate(&buf); | |
e828314e | 36 | yylval = getsstring(bufdata, 512); |
ffc11f03 CP |
37 | return STRING; |
38 | } | |
39 | \\\\ { sbaddchar(&buf, '\\'); } | |
40 | \\\" { sbaddchar(&buf, '"'); } | |
41 | [^\\] { sbaddchar(&buf, *yytext); } | |
42 | } | |
43 | ||
44 | "(" { return LPAREN; } | |
45 | ")" { return RPAREN; } | |
46 | [ \t]+ { return WHITESPACE; } | |
47 | {letter}+ { | |
e828314e | 48 | yylval = getsstring(yytext, 512); |
ffc11f03 CP |
49 | return IDENTIFIER; |
50 | } | |
51 | ||
52 | [\n\r] /* ignore */; | |
53 | ||
54 | <<EOF>> { | |
55 | BEGIN(INITIAL); | |
56 | yyterminate(); | |
57 | } | |
58 | %% |