7 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * SPDX-License-Identifier: LGPL-2.1-only
14 #include "filter-ast.hpp"
15 #include "filter-parser.hpp"
16 #include <lttng/lttng-export.h>
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 *"
30 IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
32 INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
37 UCHARLOWERCASE \\u{HEXDIGIT}{4}
38 UCHARUPPERCASE \\U{HEXDIGIT}{8}
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}+)
46 * Using start conditions to deal with comments
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);
56 "//" BEGIN(comment_sl);
57 <comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
59 L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
60 \' BEGIN(char_const); return CHARACTER_CONSTANT_START;
61 <char_const>\' BEGIN(INITIAL); return SQUOTE;
63 L\" BEGIN(string_lit); return STRING_LITERAL_START;
64 \" BEGIN(string_lit); return STRING_LITERAL_START;
65 <string_lit>\" BEGIN(INITIAL); return DQUOTE;
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;
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;
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;
112 ";" return SEMICOLON;
113 "..." return DOTDOTDOT;
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 */
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_`).
134 * The `MAKE_ALIAS` macro defines one such alias.
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)
140 return yy_create_buffer(file, size, yyscanner);
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)
147 return yy_delete_buffer(b, yyscanner);
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)
154 return yy_flush_buffer(b, yyscanner);
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)
161 return yy_scan_buffer(base, size, yyscanner);
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)
168 return yy_scan_bytes(bytes, len, yyscanner);
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)
175 return yy_scan_string(yy_str, yyscanner);
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)
182 return yy_switch_to_buffer(new_buffer, yyscanner);
186 void *lttng_yyalloc(yy_size_t s, yyscan_t yyscanner);
187 void *lttng_yyalloc(yy_size_t s, yyscan_t yyscanner)
189 return yyalloc(s, yyscanner);
193 void lttng_yyfree(void *p, yyscan_t yyscanner);
194 void lttng_yyfree(void *p, yyscan_t yyscanner)
196 return yyfree(p, yyscanner);
200 int lttng_yyget_column(yyscan_t yyscanner);
201 int lttng_yyget_column(yyscan_t yyscanner)
203 return yyget_column(yyscanner);
207 int lttng_yyget_debug(yyscan_t yyscanner);
208 int lttng_yyget_debug(yyscan_t yyscanner)
210 return yyget_debug(yyscanner);
214 YY_EXTRA_TYPE lttng_yyget_extra(yyscan_t yyscanner);
215 YY_EXTRA_TYPE lttng_yyget_extra(yyscan_t yyscanner)
217 return yyget_extra(yyscanner);
221 FILE *lttng_yyget_in(yyscan_t yyscanner);
222 FILE *lttng_yyget_in(yyscan_t yyscanner)
224 return yyget_in(yyscanner);
228 int lttng_yyget_leng(yyscan_t yyscanner);
229 int lttng_yyget_leng(yyscan_t yyscanner)
231 return yyget_leng(yyscanner);
235 int lttng_yyget_lineno(yyscan_t yyscanner);
236 int lttng_yyget_lineno(yyscan_t yyscanner)
238 return yyget_lineno(yyscanner);
242 YYSTYPE *lttng_yyget_lval(yyscan_t yyscanner);
243 YYSTYPE *lttng_yyget_lval(yyscan_t yyscanner)
245 return yyget_lval(yyscanner);
249 FILE *lttng_yyget_out(yyscan_t yyscanner);
250 FILE *lttng_yyget_out(yyscan_t yyscanner)
252 return yyget_out(yyscanner);
256 char *lttng_yyget_text(yyscan_t yyscanner);
257 char *lttng_yyget_text(yyscan_t yyscanner)
259 return yyget_text(yyscanner);
263 int lttng_yylex_init(yyscan_t *scanner);
264 int lttng_yylex_init(yyscan_t *scanner)
266 return yylex_init(scanner);
270 void lttng_yypop_buffer_state(yyscan_t yyscanner);
271 void lttng_yypop_buffer_state(yyscan_t yyscanner)
273 return yypop_buffer_state(yyscanner);
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)
280 return yypush_buffer_state(new_buffer, yyscanner);
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)
287 return yyrealloc(p, s, yyscanner);
291 void lttng_yyset_column(int _column_no, yyscan_t yyscanner);
292 void lttng_yyset_column(int _column_no, yyscan_t yyscanner)
294 return yyset_column(_column_no, yyscanner);
298 void lttng_yyset_debug(int debug_flag, yyscan_t yyscanner);
299 void lttng_yyset_debug(int debug_flag, yyscan_t yyscanner)
301 return yyset_debug(debug_flag, yyscanner);
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)
308 return yyset_extra(user_defined, yyscanner);
312 void lttng_yyset_in(FILE *_in_str, yyscan_t yyscanner);
313 void lttng_yyset_in(FILE *_in_str, yyscan_t yyscanner)
315 return yyset_in(_in_str, yyscanner);
319 void lttng_yyset_lineno(int _line_number, yyscan_t yyscanner);
320 void lttng_yyset_lineno(int _line_number, yyscan_t yyscanner)
322 return yyset_lineno(_line_number, yyscanner);
326 void lttng_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner);
327 void lttng_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner)
329 return yyset_lval(yylval_param, yyscanner);
333 void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner);
334 void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner)
336 return yyset_out(_out_str, yyscanner);