]> jfr.im git - irc/quakenet/newserv.git/blob - newsearch/newsearch.l
move some more data/log paths missed before
[irc/quakenet/newserv.git] / newsearch / newsearch.l
1 %option noyywrap
2
3 %{
4
5 #include <stdlib.h>
6 #include <string.h>
7
8 #include "../lib/sstring.h"
9
10 #define YYSTYPE sstring *
11 extern YYSTYPE yylval;
12
13 #include "y.tab.h"
14 #include "../lib/stringbuf.h"
15
16 #define MAX_STR_CONST 512
17
18 int lexpos, lexerror;
19
20 #define addpos(x) lexpos+=x;
21 #define incpos() addpos(1);
22
23 void lexreset(void) {
24 lexerror = 0;
25 lexpos = -1;
26 }
27
28 %}
29
30 digit [0-9]
31 letter [a-zA-Z]
32
33 %x str pascalstr
34 %%
35
36 char bufdata[MAX_STR_CONST];
37 StringBuf buf;
38
39 \" { incpos();
40 sbinit(&buf, bufdata, sizeof(bufdata));
41 BEGIN(str);
42 }
43
44 <str>{
45 \" { incpos();
46 BEGIN(INITIAL);
47 sbterminate(&buf);
48 yylval = getsstring(bufdata, 512);
49 return STRING;
50 }
51 \\\\ { addpos(2);
52 sbaddchar(&buf, '\\');
53 }
54 \\\" { addpos(2);
55 sbaddchar(&buf, '"');
56 }
57 [^\\] { incpos();
58 sbaddchar(&buf, *yytext);
59 }
60 }
61
62 \' { incpos();
63 sbinit(&buf, bufdata, sizeof(bufdata));
64 BEGIN(pascalstr);
65 }
66
67 <pascalstr>{
68 \'\' { addpos(2);
69 sbaddchar(&buf, '\'');
70 }
71 \' { incpos();
72 BEGIN(INITIAL);
73 sbterminate(&buf);
74 yylval = getsstring(bufdata, 512);
75 return STRING;
76 }
77 . { incpos();
78 sbaddchar(&buf, *yytext);
79 }
80 }
81
82 "(" { incpos();
83 return LPAREN;
84 }
85 ")" { incpos();
86 return RPAREN;
87 }
88 [ \t]+ { addpos(strlen(yytext));
89 return WHITESPACE;
90 }
91 ({letter}|{digit}|[#\-\+\.\*])+ { addpos(strlen(yytext));
92 yylval = getsstring(yytext, 512);
93 return IDENTIFIER;
94 }
95
96 [\n\r] { incpos();
97 /* ignore */;
98 }
99
100 . {
101 incpos();
102 lexerror = 1;
103 yyterminate();
104 }
105
106 <<EOF>> {
107 BEGIN(INITIAL);
108 yyterminate();
109 }
110 %%
111
112 void ydummyfn(void) {
113 yyunput(0, NULL);
114 }