summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/filter-scanner.l
blob: 501b603b1da5cc99f66def71ef53634001f24f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
%{
#include "smartcolsP.h"
#include "filter-parser.h"	/* define tokens (T_*) */
%}

%option reentrant bison-bridge noyywrap noinput nounput

id	[a-zA-Z][a-zA-Z_.%:/\-0-9]*
int	[0-9]+
blank	[ \t]
str_qu	\"[^\"\n]*\"
str_ap	\'[^\'\n]*\'

%%

{blank}+	;	/* ignore */
[\n]+		;	/* ignore */

"("		return '(';
")"		return ')';
"'"		return '\'';

and|AND|"&&"	return T_AND;
or|OR|"||"	return T_OR;
"!"|not|NOT	return T_NEG;

eq|EQ|"=="	return T_EQ;
ne|NE|"!="	return T_NE;

le|LE|"<="	return T_LE;
lt|LT|"<"	return T_LT;

ge|GE|">="	return T_GE;
gt|GT|">"	return T_GT;

"=~"		return T_REG;
"!~"		return T_NREG;

false|FALSE	return T_FALSE;
true|TRUE	return T_TRUE;

{int}+\.{int}+ {
	yylval->param_float = strtold(yytext, NULL);
	return T_FLOAT;
}

{int}+ {
	yylval->param_number = (int64_t) strtoumax(yytext, NULL, 10);
	return T_NUMBER;
}

{id} {
	yylval->param_name = yytext;
	return T_HOLDER;
}

{str_ap}|{str_qu} {
	yylval->param_string = yytext;
	return T_STRING;
}