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