1
/***************************************************************************
2
qgssearchstringparser.ll
3
Rules for lexical analysis of search strings done by Flex
6
copyright : (C) 2005 by Martin Dobias
7
email : won.der at centrum.sk
8
***************************************************************************/
10
/***************************************************************************
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
17
***************************************************************************/
18
/* $Id: qgssearchstringlexer.ll 5939 2006-10-12 16:24:55Z wonder $ */
21
%option case-insensitive
23
// ensure that lexer will be 8-bit (and not just 7-bit)
28
#include <stdlib.h> // atof()
30
#include "qgssearchtreenode.h"
31
#include "qgssearchstringparser.h"
39
col_first [A-Za-z_]|{non_ascii}
40
col_next [A-Za-z0-9_]|{non_ascii}
41
column_ref {col_first}{col_next}*
44
num1 {dig}+\.?([eE][-+]?{dig}+)?
45
num2 {dig}*\.{dig}+([eE][-+]?{dig}+)?
48
str_char ('')|(\\.)|[^'\\]
49
string "'"{str_char}*"'"
57
"=" { yylval.op = QgsSearchTreeNode::opEQ; return COMPARISON; }
58
"!=" { yylval.op = QgsSearchTreeNode::opNE; return COMPARISON; }
59
"<=" { yylval.op = QgsSearchTreeNode::opLE; return COMPARISON; }
60
">=" { yylval.op = QgsSearchTreeNode::opGE; return COMPARISON; }
61
"<>" { yylval.op = QgsSearchTreeNode::opNE; return COMPARISON; }
62
"<" { yylval.op = QgsSearchTreeNode::opLT; return COMPARISON; }
63
">" { yylval.op = QgsSearchTreeNode::opGT; return COMPARISON; }
64
"~" { yylval.op = QgsSearchTreeNode::opRegexp; return COMPARISON; }
65
"LIKE" { yylval.op = QgsSearchTreeNode::opLike; return COMPARISON; }
67
[+-/*] { return yytext[0]; }
69
[()] { return yytext[0]; }
71
{number} { yylval.number = atof(yytext); return NUMBER; }
73
{string} { return STRING; }
75
{column_ref} { return COLUMN_REF; }
77
{white} /* skip blanks and tabs */
79
. { return UNKNOWN_CHARACTER; }
83
void set_input_buffer(const char* buffer)
85
yy_scan_string(buffer);