]> jfr.im git - irc/quakenet/newserv.git/blob - newsearch/newsearch.l
360a5fd8dc9ea9b58bad4655f73666f759cf2d50
[irc/quakenet/newserv.git] / newsearch / newsearch.l
1 %option noyywrap
2
3 %{
4 #include "../lib/sstring.h"
5
6 #define YYSTYPE sstring *
7 extern YYSTYPE yylval;
8
9 #include "y.tab.h"
10
11 #include <stdlib.h>
12 #include "../lib/stringbuf.h"
13
14 #define MAX_STR_CONST 512
15
16 /* shuts gcc up */
17 static void yyunput (int c,char *buf_ptr);
18 void newsearch_parser_dummy(void) {
19 yyunput(0, NULL);
20 }
21
22 int fileno(void *arg) {
23 return 0;
24 }
25
26 %}
27
28 digit [0-9]
29 letter [a-zA-Z]
30
31 %x str
32 %%
33
34 char bufdata[MAX_STR_CONST];
35 StringBuf buf;
36
37 \" {
38 sbinit(&buf, bufdata, sizeof(bufdata));
39 BEGIN(str);
40 }
41
42 <str>{
43 \" {
44 BEGIN(INITIAL);
45 sbterminate(&buf);
46 yylval = getsstring(bufdata, 512);
47 return STRING;
48 }
49 \\\\ { sbaddchar(&buf, '\\'); }
50 \\\" { sbaddchar(&buf, '"'); }
51 [^\\] { sbaddchar(&buf, *yytext); }
52 }
53
54 "(" { return LPAREN; }
55 ")" { return RPAREN; }
56 [ \t]+ { return WHITESPACE; }
57 {letter}+ {
58 yylval = getsstring(yytext, 512);
59 return IDENTIFIER;
60 }
61
62 [\n\r] /* ignore */;
63
64 <<EOF>> {
65 BEGIN(INITIAL);
66 yyterminate();
67 }
68 %%