Fix: lttng: uninitialized pointer free'd when no sessiond is present
[lttng-tools.git] / src / lib / lttng-ctl / filter / filter-lexer.l
CommitLineData
953192ba
MD
1%{
2/*
3 * filter-lexer.l
4 *
5 * LTTng filter lexer
6 *
ab5be9fa 7 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
953192ba 8 *
ab5be9fa 9 * SPDX-License-Identifier: LGPL-2.1-only
953192ba 10 *
953192ba
MD
11 */
12
13#include <stdio.h>
14#include "filter-ast.h"
15#include "filter-parser.h"
16
17extern
18void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
19
20static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
21 __attribute__((unused));
22static 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 */
e90d8561
MD
30
31D [0-9]
32L [a-zA-Z_]
33H [a-fA-F0-9]
34E ([Ee][+-]?{D}+)
35P ([Pp][+-]?{D}+)
36FS (f|F|l|L)
37IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
38
953192ba
MD
39INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
40DIGIT [0-9]
41NONDIGIT [a-zA-Z_]
42HEXDIGIT [0-9A-Fa-f]
43OCTALDIGIT [0-7]
44UCHARLOWERCASE \\u{HEXDIGIT}{4}
45UCHARUPPERCASE \\U{HEXDIGIT}{8}
bff988fa 46ID_EXTRA_CHAR (":")
a1f68b22 47ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}|{ID_EXTRA_CHAR}
953192ba
MD
48IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
49ESCSEQ \\(\'|\"|\?|\\|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
66L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
67\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
68<char_const>\' BEGIN(INITIAL); return SQUOTE;
69
70L\" 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
e90d8561
MD
78
790[xX]{H}+{IS}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
800[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;
860[xX]{H}+{P}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
870[xX]{H}*"."{H}+{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
880[xX]{H}+"."{H}*{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
89
953192ba
MD
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;
586dc72f 128"$"{IDENTIFIER} printf_debug("<GLOBAL_IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return GLOBAL_IDENTIFIER;
953192ba
MD
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.104529 seconds and 5 git commands to generate.