void Datum::Reader::ReadSymbol() { std::string atomic_text; if(*Cursor == '|') atomic_text = ReadQuoted('|'); else atomic_text = ReadAtomicText(); Red.reset(new Symbol(atomic_text)); return; }
std::unique_ptr<Datum> Datum::Reader::ReadAtom() { if(*Cursor == '"') return std::unique_ptr<Atom>(new String(ReadQuoted('"'))); else if(*Cursor == '|') return std::unique_ptr<Atom>(new Symbol(ReadQuoted('|'))); else { std::string atom_text = ReadAtomicText(); Datum::Reader details(atom_text); if(details.Parse(&Reader::ReadTimestamp)) return std::unique_ptr<Datum>(details.Red.release()); if(details.Parse(&Reader::ReadNumber)) return std::unique_ptr<Datum>(details.Red.release()); return std::unique_ptr<Datum>(new Symbol(atom_text)); }}
bool Lexer::GetNextToken(QueryToken* token) { while(!reader->Eos()) { int ch = reader->GetNext(); if ( ch == -1 ) break; // skipping whitespaces if( _istspace(ch)!=0 ) { continue; } TCHAR buf[2] = {TCHAR(ch),'\0'}; switch(ch) { case '+': token->set(buf, QueryToken::PLUS); return true; case '-': token->set(buf, QueryToken::MINUS); return true; case '(': token->set(buf, QueryToken::LPAREN); return true; case ')': token->set(buf, QueryToken::RPAREN); return true; case ':': token->set(buf, QueryToken::COLON); return true; case '!': token->set(buf, QueryToken::NOT); return true; case '^': token->set(buf, QueryToken::CARAT); return true; case '~': if( _istdigit( reader->Peek() )!=0 ) { TCHAR number[LUCENE_MAX_FIELD_LEN]; ReadIntegerNumber(ch, number,LUCENE_MAX_FIELD_LEN); token->set(number, QueryToken::SLOP); return true; }else{ token->set(buf, QueryToken::FUZZY); return true; } break; case '"': return ReadQuoted(ch, token); case '[': return ReadInclusiveRange(ch, token); case '{': return ReadExclusiveRange(ch, token); case ']': case '}': case '*': queryparser->throwParserException( _T("Unrecognized TCHAR %d at %d::%d."), ch, reader->Column(), reader->Line() ); return false; default: return ReadTerm(ch, token); // end of swith } } return false; }
void Datum::Reader::ReadString() { Red.reset(new String(ReadQuoted('"'))); return; }