pike.git / lib / modules / Search.pmod / Grammar.pmod / DefaultParser.pike

version» Context lines:

pike.git/lib/modules/Search.pmod/Grammar.pmod/DefaultParser.pike:75:   }      static void advance() {    if (sizeof(tokens) > 1)    tokens = tokens[1 .. ];   }      static int lookingAtFieldStart(void|int offset) {    multiset(string) fields = options["fields"];    // SHOW(tokens); -  return peek(offset)[0] == TOKEN_WORD +  return peek(offset)[0] == TOKEN_TEXT    && fields[ lower_case(peek(offset)[1]) ]    && peek(offset + 1)[0] == TOKEN_COLON;   }      static void create(mapping(string:mixed)|void opt) {    options = opt || ([ "implicit" : "or" ]);    if (!options["fields"])    options["fields"] = getDefaultFields();   }   
pike.git/lib/modules/Search.pmod/Grammar.pmod/DefaultParser.pike:214:    for (;;) {    parseExpr6(text);    if ( (< TOKEN_END,    TOKEN_RPAREN,    TOKEN_AND,    TOKEN_OR >) [ peek()[0] ]    || lookingAtFieldStart()    || (peek()[0] == TOKEN_LPAREN))    break; // it was a higher level IMPLICIT AND    if (peek()[0] == TOKEN_OR) -  if (peek(1)[0] == TOKEN_WORD -  && peek(2)[0] == TOKEN_COLON +  if (lookingAtFieldStart(1)    || peek(1)[0] == TOKEN_LPAREN)    break; // it was a higher level OR    else    advance();    }    if (sizeof(text->words)    || sizeof(text->phrases)    || sizeof(text->plusWords)    || sizeof(text->plusPhrases)    || sizeof(text->minusWords)
pike.git/lib/modules/Search.pmod/Grammar.pmod/DefaultParser.pike:247:    prefix = '-';    }    else if (peek()[0] == TOKEN_PLUS) {    advance();    prefix = '+';    }       if (!prefix && options["implicit"] == "and")    prefix = '+';    -  while (!(< TOKEN_PHRASE, -  TOKEN_WORD, -  TOKEN_END >) [ peek()[0] ]) +  while (!(< TOKEN_TEXT, TOKEN_END >) [ peek()[0] ])    advance(); // ... ????????? or something smarter ?????    -  if (peek()[0] == TOKEN_PHRASE -  || peek()[0] == TOKEN_WORD) { -  string phrase = peek()[1]; +  if (peek()[0] == TOKEN_TEXT) { +  string text = peek()[1];    advance(); -  array(string) words = Unicode.split_words_and_normalize(phrase); +  array(string) words = Unicode.split_words_and_normalize(text);    if (!words || !sizeof(words))    return;    if (sizeof(words) == 1)    switch (prefix) {    case '+': node->plusWords += words; break;    case '-': node->minusWords += words; break;    default: node->words += words; break;    }    else if (sizeof(words) > 1)    switch (prefix) {
pike.git/lib/modules/Search.pmod/Grammar.pmod/DefaultParser.pike:281:    }   }      static ParseNode parseDate() {    // TRACE;    DateNode n = DateNode();    n->date = "";   loop:    for (;;) {    switch (peek()[0]) { -  case TOKEN_WORD: +  case TOKEN_TEXT:    if (lookingAtFieldStart())    break loop; // it's a field specifier    break; -  case TOKEN_UNKNOWN: +     case TOKEN_MINUS:    case TOKEN_COLON:    break;    default:    break loop;    }    n->date += peek()[2]; // with spaces preserved!    advance();    }    return n;   }