lib: compile liblttng-ctl as C++
[lttng-tools.git] / src / common / filter / filter-lexer.l
1 %{
2 /*
3 * filter-lexer.l
4 *
5 * LTTng filter lexer
6 *
7 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * SPDX-License-Identifier: LGPL-2.1-only
10 *
11 */
12
13 #include <stdio.h>
14 #include "filter-ast.h"
15 #include "filter-parser.h"
16 #include <lttng/lttng-export.h>
17
18 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
19 __attribute__((unused));
20 static int input (yyscan_t yyscanner) __attribute__((unused));
21
22 %}
23
24 %x comment_ml comment_sl string_lit char_const
25 %option reentrant yylineno noyywrap bison-bridge
26 %option extra-type="struct filter_parser_ctx *"
27 /* bison-locations */
28
29 D [0-9]
30 L [a-zA-Z_]
31 H [a-fA-F0-9]
32 E ([Ee][+-]?{D}+)
33 P ([Pp][+-]?{D}+)
34 FS (f|F|l|L)
35 IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
36
37 INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
38 DIGIT [0-9]
39 NONDIGIT [a-zA-Z_]
40 HEXDIGIT [0-9A-Fa-f]
41 OCTALDIGIT [0-7]
42 UCHARLOWERCASE \\u{HEXDIGIT}{4}
43 UCHARUPPERCASE \\U{HEXDIGIT}{8}
44 ID_EXTRA_CHAR (":")
45 ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}|{ID_EXTRA_CHAR}
46 IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
47 ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+)
48 %%
49
50 /*
51 * Using start conditions to deal with comments
52 * and strings.
53 */
54
55 "/*" BEGIN(comment_ml);
56 <comment_ml>[^*\n]* /* eat anything that's not a '*' */
57 <comment_ml>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
58 <comment_ml>\n ++yylineno;
59 <comment_ml>"*"+"/" BEGIN(INITIAL);
60
61 "//" BEGIN(comment_sl);
62 <comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
63
64 L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
65 \' BEGIN(char_const); return CHARACTER_CONSTANT_START;
66 <char_const>\' BEGIN(INITIAL); return SQUOTE;
67
68 L\" BEGIN(string_lit); return STRING_LITERAL_START;
69 \" BEGIN(string_lit); return STRING_LITERAL_START;
70 <string_lit>\" BEGIN(INITIAL); return DQUOTE;
71
72 <char_const,string_lit>ESCSEQ return ESCSEQ;
73 <char_const,string_lit>\n ; /* ignore */
74 <char_const,string_lit>. setstring(yyextra, yylval, yytext); return CHAR_STRING_TOKEN;
75
76
77 0[xX]{H}+{IS}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
78 0[0-7]*{IS}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
79 [1-9]{D}*{IS}? setstring(yyextra, yylval, yytext); return DECIMAL_CONSTANT;
80
81 {D}+{E}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
82 {D}*"."{D}+{E}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
83 {D}+"."{D}*{E}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
84 0[xX]{H}+{P}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
85 0[xX]{H}*"."{H}+{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
86 0[xX]{H}+"."{H}*{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
87
88 "[" return LSBRAC;
89 "]" return RSBRAC;
90 "(" return LPAREN;
91 ")" return RPAREN;
92 "{" return LBRAC;
93 "}" return RBRAC;
94 "->" return RARROW;
95
96 "*" return STAR;
97 "+" return PLUS;
98 "-" return MINUS;
99
100 "%" return MOD_OP;
101 "/" return DIV_OP;
102 ">>" return RIGHT_OP;
103 "<<" return LEFT_OP;
104
105 "==" return EQ_OP;
106 "!=" return NE_OP;
107 "<=" return LE_OP;
108 ">=" return GE_OP;
109 "<" return LT_OP;
110 ">" return GT_OP;
111 "&&" return AND_OP;
112 "||" return OR_OP;
113 "!" return NOT_OP;
114
115 ":=" return ASSIGN;
116 ":" return COLON;
117 ";" return SEMICOLON;
118 "..." return DOTDOTDOT;
119 "." return DOT;
120 "=" return EQUAL;
121 "," return COMMA;
122 "^" return XOR_BIN;
123 "&" return AND_BIN;
124 "|" return OR_BIN;
125 "~" return NOT_BIN;
126 "$"{IDENTIFIER} printf_debug("<GLOBAL_IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return GLOBAL_IDENTIFIER;
127 {IDENTIFIER} printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return IDENTIFIER;
128 [ \t\n]+ ; /* ignore */
129 . return ERROR;
130 %%
131
132 /*
133 * The lexer symbols were (e.g. lttng_yy_create_buffer) were mistakenly
134 * exported in the past, so must stay exported. Since it is difficult to tweak
135 * how the lexer functions are emitted, the strategy used here was to use a
136 * different prefix for the symbols (`lttng_filter_`) and define aliases with
137 * the old prefix (`lttng_`).
138 *
139 * The `MAKE_ALIAS` macro defines one such alias.
140 */
141 LTTNG_EXPORT
142 YY_BUFFER_STATE lttng_yy_create_buffer(FILE *file, int size, yyscan_t yyscanner);
143 YY_BUFFER_STATE lttng_yy_create_buffer(FILE *file, int size, yyscan_t yyscanner)
144 {
145 return yy_create_buffer(file, size, yyscanner);
146 }
147
148 LTTNG_EXPORT
149 void lttng_yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner);
150 void lttng_yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)
151 {
152 return yy_delete_buffer(b, yyscanner);
153 }
154
155 LTTNG_EXPORT
156 void lttng_yy_flush_buffer (YY_BUFFER_STATE b, yyscan_t yyscanner);
157 void lttng_yy_flush_buffer (YY_BUFFER_STATE b, yyscan_t yyscanner)
158 {
159 return yy_flush_buffer(b, yyscanner);
160 }
161
162 LTTNG_EXPORT
163 YY_BUFFER_STATE lttng_yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner);
164 YY_BUFFER_STATE lttng_yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner)
165 {
166 return yy_scan_buffer(base, size, yyscanner);
167 }
168
169 LTTNG_EXPORT
170 YY_BUFFER_STATE lttng_yy_scan_bytes(const char *bytes, int len, yyscan_t yyscanner);
171 YY_BUFFER_STATE lttng_yy_scan_bytes(const char *bytes, int len, yyscan_t yyscanner)
172 {
173 return yy_scan_bytes(bytes, len, yyscanner);
174 }
175
176 LTTNG_EXPORT
177 YY_BUFFER_STATE lttng_yy_scan_string(const char *yy_str, yyscan_t yyscanner);
178 YY_BUFFER_STATE lttng_yy_scan_string(const char *yy_str, yyscan_t yyscanner)
179 {
180 return yy_scan_string(yy_str, yyscanner);
181 }
182
183 LTTNG_EXPORT
184 void lttng_yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner);
185 void lttng_yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
186 {
187 return yy_switch_to_buffer(new_buffer, yyscanner);
188 }
189
190 LTTNG_EXPORT
191 void *lttng_yyalloc(yy_size_t s, yyscan_t yyscanner);
192 void *lttng_yyalloc(yy_size_t s, yyscan_t yyscanner)
193 {
194 return yyalloc(s, yyscanner);
195 }
196
197 LTTNG_EXPORT
198 void lttng_yyfree(void *p, yyscan_t yyscanner);
199 void lttng_yyfree(void *p, yyscan_t yyscanner)
200 {
201 return yyfree(p, yyscanner);
202 }
203
204 LTTNG_EXPORT
205 int lttng_yyget_column(yyscan_t yyscanner);
206 int lttng_yyget_column(yyscan_t yyscanner)
207 {
208 return yyget_column(yyscanner);
209 }
210
211 LTTNG_EXPORT
212 int lttng_yyget_debug(yyscan_t yyscanner);
213 int lttng_yyget_debug(yyscan_t yyscanner)
214 {
215 return yyget_debug(yyscanner);
216 }
217
218 LTTNG_EXPORT
219 YY_EXTRA_TYPE lttng_yyget_extra(yyscan_t yyscanner);
220 YY_EXTRA_TYPE lttng_yyget_extra(yyscan_t yyscanner)
221 {
222 return yyget_extra(yyscanner);
223 }
224
225 LTTNG_EXPORT
226 FILE *lttng_yyget_in(yyscan_t yyscanner);
227 FILE *lttng_yyget_in(yyscan_t yyscanner)
228 {
229 return yyget_in(yyscanner);
230 }
231
232 LTTNG_EXPORT
233 int lttng_yyget_leng(yyscan_t yyscanner);
234 int lttng_yyget_leng(yyscan_t yyscanner)
235 {
236 return yyget_leng(yyscanner);
237 }
238
239 LTTNG_EXPORT
240 int lttng_yyget_lineno(yyscan_t yyscanner);
241 int lttng_yyget_lineno(yyscan_t yyscanner)
242 {
243 return yyget_lineno(yyscanner);
244 }
245
246 LTTNG_EXPORT
247 YYSTYPE *lttng_yyget_lval(yyscan_t yyscanner);
248 YYSTYPE *lttng_yyget_lval(yyscan_t yyscanner)
249 {
250 return yyget_lval(yyscanner);
251 }
252
253 LTTNG_EXPORT
254 FILE *lttng_yyget_out(yyscan_t yyscanner);
255 FILE *lttng_yyget_out(yyscan_t yyscanner)
256 {
257 return yyget_out(yyscanner);
258 }
259
260 LTTNG_EXPORT
261 char *lttng_yyget_text(yyscan_t yyscanner);
262 char *lttng_yyget_text(yyscan_t yyscanner)
263 {
264 return yyget_text(yyscanner);
265 }
266
267 LTTNG_EXPORT
268 int lttng_yylex_init(yyscan_t *scanner);
269 int lttng_yylex_init(yyscan_t *scanner)
270 {
271 return yylex_init(scanner);
272 }
273
274 LTTNG_EXPORT
275 void lttng_yypop_buffer_state(yyscan_t yyscanner);
276 void lttng_yypop_buffer_state(yyscan_t yyscanner)
277 {
278 return yypop_buffer_state(yyscanner);
279 }
280
281 LTTNG_EXPORT
282 void lttng_yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner);
283 void lttng_yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
284 {
285 return yypush_buffer_state(new_buffer, yyscanner);
286 }
287
288 LTTNG_EXPORT
289 void *lttng_yyrealloc(void *p, yy_size_t s, yyscan_t yyscanner);
290 void *lttng_yyrealloc(void *p, yy_size_t s, yyscan_t yyscanner)
291 {
292 return yyrealloc(p, s, yyscanner);
293 }
294
295 LTTNG_EXPORT
296 void lttng_yyset_column(int _column_no, yyscan_t yyscanner);
297 void lttng_yyset_column(int _column_no, yyscan_t yyscanner)
298 {
299 return yyset_column(_column_no, yyscanner);
300 }
301
302 LTTNG_EXPORT
303 void lttng_yyset_debug(int debug_flag, yyscan_t yyscanner);
304 void lttng_yyset_debug(int debug_flag, yyscan_t yyscanner)
305 {
306 return yyset_debug(debug_flag, yyscanner);
307 }
308
309 LTTNG_EXPORT
310 void lttng_yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner);
311 void lttng_yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner)
312 {
313 return yyset_extra(user_defined, yyscanner);
314 }
315
316 LTTNG_EXPORT
317 void lttng_yyset_in(FILE *_in_str, yyscan_t yyscanner);
318 void lttng_yyset_in(FILE *_in_str, yyscan_t yyscanner)
319 {
320 return yyset_in(_in_str, yyscanner);
321 }
322
323 LTTNG_EXPORT
324 void lttng_yyset_lineno(int _line_number, yyscan_t yyscanner);
325 void lttng_yyset_lineno(int _line_number, yyscan_t yyscanner)
326 {
327 return yyset_lineno(_line_number, yyscanner);
328 }
329
330 LTTNG_EXPORT
331 void lttng_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner);
332 void lttng_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner)
333 {
334 return yyset_lval(yylval_param, yyscanner);
335 }
336
337 LTTNG_EXPORT
338 void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner);
339 void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner)
340 {
341 return yyset_out(_out_str, yyscanner);
342 }
This page took 0.037575 seconds and 4 git commands to generate.