summaryrefslogtreecommitdiffstats
path: root/libcli/wsp/wsp_aqs_lexer.l
blob: dff4c1042b08a800e236eba8bba1f49ecb6116f8 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 *  Unix SMB/CIFS implementation.
 *
 *  Window Search Service
 *
 *  Copyright (c) Noel Power
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

%{

#include "includes.h"
#include "libcli/wsp/wsp_aqs.h"
#include "libcli/wsp/wsp_aqs_parser.tab.h"


#include <stdio.h>

#define YY_NO_INPUT

%}

%option warn nodefault nounput

%option reentrant noyywrap never-interactive nounistd
%option bison-bridge

LPAREN	"("
RPAREN	")"
AND	"AND"
OR	"OR"
NOT	"NOT"
EQ	"=="
NE	"!="
GE	">="
LE	"<="
LESS	"<"
GREATER	">"
COMMA	","
WHERE	"WHERE"
SELECT	"SELECT"
PROP_EQUALS	":"
TRUE	"true"
FALSE	"false"

TODAY		"today"
YESTERDAY	"yesterday"
THISWEEK	"thisweek"
LASTWEEK	"lastweek"
THISMONTH	"thismonth"
LASTMONTH	"lastmonth"
THISYEAR	"thisyear"
LASTYEAR	"lastyear"

EMPTY		"empty"
TINY		"tiny"
SMALL		"small"
MEDIUM		"medium"
LARGE		"large"
HUGE		"huge"
GIGANTIC	"gigantic"

STARTS_WITH "$<"
EQUALS      "$="
K	    "K"
M	    "M"
G	    "G"
T	    "T"
KB	    "KB"
MB	    "MB"
GB	    "GB"
TB	    "TB"
RANGE	    "-"


NUMBER		[0-9]+
WS		[ \r\n\t]*
IDENTIFIER	[a-z\."A-Z_][a-z\."A-Z_0-9]*
STRING_LITERAL  L?\"(\\.|[^\\"])*\"

%%

{WS}		{ /* Skip blanks. */ }

{NUMBER}        { sscanf(yytext, "%"PRId64, &yylval->num); return TOKEN_NUMBER; }

{AND}		{ return TOKEN_AND; }
{OR}		{ return TOKEN_OR; }
{NOT}		{ return TOKEN_NOT; }
{EQ}		{ return TOKEN_EQ; }
{NE}		{ return TOKEN_NE; }
{GE}		{ return TOKEN_GE; }
{LE}		{ return TOKEN_LE; }
{LESS}		{ return TOKEN_LT; }
{GREATER}	{ return TOKEN_GT; }
{LPAREN}	{ return TOKEN_LPAREN; }
{RPAREN}	{ return TOKEN_RPAREN; }
{COMMA}		{ return TOKEN_COMMA; }
{WHERE}		{ return TOKEN_WHERE; }
{SELECT}	{ return TOKEN_SELECT; }
{TRUE}		{ return TOKEN_TRUE; }
{FALSE}		{ return TOKEN_FALSE; }
{PROP_EQUALS}	{ return TOKEN_PROP_EQUALS; }

{STARTS_WITH}	{ return TOKEN_STARTS_WITH;}
{EQUALS}	{ return TOKEN_EQUALS;}

{K}	{ return TOKEN_K; }
{M}	{ return TOKEN_M; }
{G}	{ return TOKEN_G; }
{T}	{ return TOKEN_T; }
{KB}	{ return TOKEN_KB; }
{MB}	{ return TOKEN_MB; }
{GB}	{ return TOKEN_GB; }
{TB}	{ return TOKEN_TB; }
{RANGE}	{ return TOKEN_RANGE; }
{TODAY} { return TOKEN_TODAY; }
{YESTERDAY} { return TOKEN_YESTERDAY;}
{THISWEEK} { return TOKEN_THISWEEK;}
{LASTWEEK} { return TOKEN_LASTWEEK;}
{THISMONTH} { return TOKEN_THISMONTH; }
{LASTMONTH} { return TOKEN_LASTMONTH; }
{THISYEAR} { return TOKEN_THISYEAR; }
{LASTYEAR} { return TOKEN_LASTYEAR; }
{EMPTY}    { return TOKEN_EMPTY; }
{TINY}     { return TOKEN_TINY; }
{SMALL}    { return TOKEN_SMALL; }
{MEDIUM}   { return TOKEN_MEDIUM; }
{LARGE}    { return TOKEN_LARGE; }
{HUGE}     { return TOKEN_HUGE; }
{GIGANTIC} { return TOKEN_GIGANTIC; }


{STRING_LITERAL} { yylval->strval = talloc_asprintf(talloc_tos(), "%s", yytext); return TOKEN_STRING_LITERAL; }

{IDENTIFIER}	{ yylval->strval = talloc_asprintf(talloc_tos(), "%s", yytext); return TOKEN_IDENTIFIER; }
.               {  }

%%