Fix: lttng: uninitialized pointer free'd when no sessiond is present
[lttng-tools.git] / src / lib / lttng-ctl / 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
17 extern
18 void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
19
20 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
21 __attribute__((unused));
22 static int input (yyscan_t yyscanner) __attribute__((unused));
23
24 %}
25
26 %x comment_ml comment_sl string_lit char_const
27 %option reentrant yylineno noyywrap bison-bridge
28 %option extra-type="struct filter_parser_ctx *"
29 /* bison-locations */
30
31 D [0-9]
32 L [a-zA-Z_]
33 H [a-fA-F0-9]
34 E ([Ee][+-]?{D}+)
35 P ([Pp][+-]?{D}+)
36 FS (f|F|l|L)
37 IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
38
39 INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
40 DIGIT [0-9]
41 NONDIGIT [a-zA-Z_]
42 HEXDIGIT [0-9A-Fa-f]
43 OCTALDIGIT [0-7]
44 UCHARLOWERCASE \\u{HEXDIGIT}{4}
45 UCHARUPPERCASE \\U{HEXDIGIT}{8}
46 ID_EXTRA_CHAR (":")
47 ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}|{ID_EXTRA_CHAR}
48 IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
49 ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+)
50 %%
51
52 /*
53 * Using start conditions to deal with comments
54 * and strings.
55 */
56
57 "/*" BEGIN(comment_ml);
58 <comment_ml>[^*\n]* /* eat anything that's not a '*' */
59 <comment_ml>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
60 <comment_ml>\n ++yylineno;
61 <comment_ml>"*"+"/" BEGIN(INITIAL);
62
63 "//" BEGIN(comment_sl);
64 <comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
65
66 L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
67 \' BEGIN(char_const); return CHARACTER_CONSTANT_START;
68 <char_const>\' BEGIN(INITIAL); return SQUOTE;
69
70 L\" BEGIN(string_lit); return STRING_LITERAL_START;
71 \" BEGIN(string_lit); return STRING_LITERAL_START;
72 <string_lit>\" BEGIN(INITIAL); return DQUOTE;
73
74 <char_const,string_lit>ESCSEQ return ESCSEQ;
75 <char_const,string_lit>\n ; /* ignore */
76 <char_const,string_lit>. setstring(yyextra, yylval, yytext); return CHAR_STRING_TOKEN;
77
78
79 0[xX]{H}+{IS}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
80 0[0-7]*{IS}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
81 [1-9]{D}*{IS}? setstring(yyextra, yylval, yytext); return DECIMAL_CONSTANT;
82
83 {D}+{E}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
84 {D}*"."{D}+{E}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
85 {D}+"."{D}*{E}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
86 0[xX]{H}+{P}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
87 0[xX]{H}*"."{H}+{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
88 0[xX]{H}+"."{H}*{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
89
90 "[" return LSBRAC;
91 "]" return RSBRAC;
92 "(" return LPAREN;
93 ")" return RPAREN;
94 "{" return LBRAC;
95 "}" return RBRAC;
96 "->" return RARROW;
97
98 "*" return STAR;
99 "+" return PLUS;
100 "-" return MINUS;
101
102 "%" return MOD_OP;
103 "/" return DIV_OP;
104 ">>" return RIGHT_OP;
105 "<<" return LEFT_OP;
106
107 "==" return EQ_OP;
108 "!=" return NE_OP;
109 "<=" return LE_OP;
110 ">=" return GE_OP;
111 "<" return LT_OP;
112 ">" return GT_OP;
113 "&&" return AND_OP;
114 "||" return OR_OP;
115 "!" return NOT_OP;
116
117 ":=" return ASSIGN;
118 ":" return COLON;
119 ";" return SEMICOLON;
120 "..." return DOTDOTDOT;
121 "." return DOT;
122 "=" return EQUAL;
123 "," return COMMA;
124 "^" return XOR_BIN;
125 "&" return AND_BIN;
126 "|" return OR_BIN;
127 "~" return NOT_BIN;
128 "$"{IDENTIFIER} printf_debug("<GLOBAL_IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return GLOBAL_IDENTIFIER;
129 {IDENTIFIER} printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return IDENTIFIER;
130 [ \t\n]+ ; /* ignore */
131 . return ERROR;
132 %%
This page took 0.034261 seconds and 6 git commands to generate.