mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Improve search engine with new operators and new fields
This commit is contained in:
@ -17,6 +17,14 @@ Token QueryLexer::next()
|
||||
case '(':
|
||||
case ')':
|
||||
return single(Token::Type::opcode);
|
||||
case ':':
|
||||
return single(Token::Type::equal);
|
||||
case '=':
|
||||
return equal();
|
||||
case '<':
|
||||
return minor();
|
||||
case '>':
|
||||
return major();
|
||||
case '"':
|
||||
return quotedWord();
|
||||
default:
|
||||
@ -44,7 +52,7 @@ Token QueryLexer::word()
|
||||
auto start = index;
|
||||
get();
|
||||
auto current = peek();
|
||||
while (current != '\0' && !isSpace(current) && current != '"' && current != '(' && current != ')') {
|
||||
while (current != '\0' && !isSpace(current) && current != '"' && current != '(' && current != ')' && current != ':' && current != '=' && current != '<' && current != '>') {
|
||||
get();
|
||||
current = peek();
|
||||
}
|
||||
@ -70,6 +78,45 @@ Token QueryLexer::quotedWord()
|
||||
return Token(Token::Type::eof);
|
||||
}
|
||||
|
||||
Token QueryLexer::minor()
|
||||
{
|
||||
auto start = index;
|
||||
get();
|
||||
auto current = peek();
|
||||
if (current == '=') {
|
||||
get();
|
||||
return Token(Token::Type::minorOrEqual, input.substr(start, index - start));
|
||||
}
|
||||
|
||||
return Token(Token::Type::minor, input.substr(start, index - start));
|
||||
}
|
||||
|
||||
Token QueryLexer::major()
|
||||
{
|
||||
auto start = index;
|
||||
get();
|
||||
auto current = peek();
|
||||
if (current == '=') {
|
||||
get();
|
||||
return Token(Token::Type::majorOrEqual, input.substr(start, index - start));
|
||||
}
|
||||
|
||||
return Token(Token::Type::major, input.substr(start, index - start));
|
||||
}
|
||||
|
||||
Token QueryLexer::equal()
|
||||
{
|
||||
auto start = index;
|
||||
get();
|
||||
auto current = peek();
|
||||
if (current == '=') {
|
||||
get();
|
||||
return Token(Token::Type::exactEqual, input.substr(start, index - start));
|
||||
}
|
||||
|
||||
return Token(Token::Type::equal, input.substr(start, index - start));
|
||||
}
|
||||
|
||||
bool QueryLexer::isSpace(char c)
|
||||
{
|
||||
switch (c) {
|
||||
|
Reference in New Issue
Block a user