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