7 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * SPDX-License-Identifier: LGPL-2.1-only
14 #include "filter-ast.h"
15 #include "filter-parser.h"
16 #include <lttng/lttng-export.h>
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));
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 *"
35 IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
37 INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
42 UCHARLOWERCASE \\u{HEXDIGIT}{4}
43 UCHARUPPERCASE \\U{HEXDIGIT}{8}
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}+)
51 * Using start conditions to deal with comments
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);
61 "//" BEGIN(comment_sl);
62 <comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
64 L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
65 \' BEGIN(char_const); return CHARACTER_CONSTANT_START;
66 <char_const>\' BEGIN(INITIAL); return SQUOTE;
68 L\" BEGIN(string_lit); return STRING_LITERAL_START;
69 \" BEGIN(string_lit); return STRING_LITERAL_START;
70 <string_lit>\" BEGIN(INITIAL); return DQUOTE;
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;
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;
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;
102 ">>" return RIGHT_OP;
117 ";" return SEMICOLON;
118 "..." return DOTDOTDOT;
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 */
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_`).
139 * The `MAKE_ALIAS` macro defines one such alias.
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)
145 return yy_create_buffer(file, size, yyscanner);
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)
152 return yy_delete_buffer(b, yyscanner);
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)
159 return yy_flush_buffer(b, yyscanner);
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)
166 return yy_scan_buffer(base, size, yyscanner);
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)
173 return yy_scan_bytes(bytes, len, yyscanner);
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)
180 return yy_scan_string(yy_str, yyscanner);
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)
187 return yy_switch_to_buffer(new_buffer, yyscanner);
191 void *lttng_yyalloc(yy_size_t s, yyscan_t yyscanner);
192 void *lttng_yyalloc(yy_size_t s, yyscan_t yyscanner)
194 return yyalloc(s, yyscanner);
198 void lttng_yyfree(void *p, yyscan_t yyscanner);
199 void lttng_yyfree(void *p, yyscan_t yyscanner)
201 return yyfree(p, yyscanner);
205 int lttng_yyget_column(yyscan_t yyscanner);
206 int lttng_yyget_column(yyscan_t yyscanner)
208 return yyget_column(yyscanner);
212 int lttng_yyget_debug(yyscan_t yyscanner);
213 int lttng_yyget_debug(yyscan_t yyscanner)
215 return yyget_debug(yyscanner);
219 YY_EXTRA_TYPE lttng_yyget_extra(yyscan_t yyscanner);
220 YY_EXTRA_TYPE lttng_yyget_extra(yyscan_t yyscanner)
222 return yyget_extra(yyscanner);
226 FILE *lttng_yyget_in(yyscan_t yyscanner);
227 FILE *lttng_yyget_in(yyscan_t yyscanner)
229 return yyget_in(yyscanner);
233 int lttng_yyget_leng(yyscan_t yyscanner);
234 int lttng_yyget_leng(yyscan_t yyscanner)
236 return yyget_leng(yyscanner);
240 int lttng_yyget_lineno(yyscan_t yyscanner);
241 int lttng_yyget_lineno(yyscan_t yyscanner)
243 return yyget_lineno(yyscanner);
247 YYSTYPE *lttng_yyget_lval(yyscan_t yyscanner);
248 YYSTYPE *lttng_yyget_lval(yyscan_t yyscanner)
250 return yyget_lval(yyscanner);
254 FILE *lttng_yyget_out(yyscan_t yyscanner);
255 FILE *lttng_yyget_out(yyscan_t yyscanner)
257 return yyget_out(yyscanner);
261 char *lttng_yyget_text(yyscan_t yyscanner);
262 char *lttng_yyget_text(yyscan_t yyscanner)
264 return yyget_text(yyscanner);
268 int lttng_yylex_init(yyscan_t *scanner);
269 int lttng_yylex_init(yyscan_t *scanner)
271 return yylex_init(scanner);
275 void lttng_yypop_buffer_state(yyscan_t yyscanner);
276 void lttng_yypop_buffer_state(yyscan_t yyscanner)
278 return yypop_buffer_state(yyscanner);
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)
285 return yypush_buffer_state(new_buffer, yyscanner);
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)
292 return yyrealloc(p, s, yyscanner);
296 void lttng_yyset_column(int _column_no, yyscan_t yyscanner);
297 void lttng_yyset_column(int _column_no, yyscan_t yyscanner)
299 return yyset_column(_column_no, yyscanner);
303 void lttng_yyset_debug(int debug_flag, yyscan_t yyscanner);
304 void lttng_yyset_debug(int debug_flag, yyscan_t yyscanner)
306 return yyset_debug(debug_flag, yyscanner);
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)
313 return yyset_extra(user_defined, yyscanner);
317 void lttng_yyset_in(FILE *_in_str, yyscan_t yyscanner);
318 void lttng_yyset_in(FILE *_in_str, yyscan_t yyscanner)
320 return yyset_in(_in_str, yyscanner);
324 void lttng_yyset_lineno(int _line_number, yyscan_t yyscanner);
325 void lttng_yyset_lineno(int _line_number, yyscan_t yyscanner)
327 return yyset_lineno(_line_number, yyscanner);
331 void lttng_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner);
332 void lttng_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner)
334 return yyset_lval(yylval_param, yyscanner);
338 void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner);
339 void lttng_yyset_out(FILE *_out_str, yyscan_t yyscanner)
341 return yyset_out(_out_str, yyscanner);