pike.git / lib / modules / Search.pmod / Query.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Query.pmod:77:   //! All wanted words in the query. (I.e. not the words that were   //! preceded by minus.)   //! @endarray   //!   array(Search.ResultSet|array(string)) execute(Search.Database.Base db,    Search.Grammar.AbstractParser parser,    string query,    Search.RankingProfile defaultRanking)   {    Search.Grammar.ParseNode q = parser->parse(query); +     q = Search.Grammar.optimize(q);       if (!q) // The query was a null query    return ({ Search.ResultSet(), ({}) }); // so return an empty resultset       string error = Search.Grammar.validate(q);    if (error)    throw (error);    -  werror("Search.Query.execute:\n%s\n", q->print()); -  +     return class {    static Search.RankingProfile defaultRanking;    static Search.Database.Base db;       // Used when search is limited to another field than "any:".    static Search.RankingProfile specialRanking;       static void create(Search.Database.Base _db, Search.RankingProfile _defaultRanking) {    db = _db;    defaultRanking = _defaultRanking;    specialRanking = defaultRanking->copy();    }       static constant ParseNode = Search.Grammar.ParseNode;       static array(array(string)|string) words = ({ });    static array(Search.ResultSet) stack = ({ });    static void push(Search.ResultSet r) { -  werror("---PUSH\n"); +  // werror("---PUSH\n");    stack = ({ r }) + stack;    }    static Search.ResultSet pop() { -  werror("---POP\n"); +  // werror("---POP\n");    if (!sizeof(stack))    error("Very bad!");    Search.ResultSet r = stack[0];    stack = stack[1 .. ];    return r;    }       array(Search.ResultSet|array(string)) execute(ParseNode q) {    exec(q);    if (sizeof(stack) != 1)    throw ("Stack should have exactly one item!");    return ({ pop(), words });    }       void exec(ParseNode q) { -  werror("EXEC %s\n", q->op); +  // werror("EXEC %s\n", q->op);    switch (q->op) {    case "and":    {    int first = 1;    foreach (q->children, ParseNode child)    if (child->op != "date") {    exec(child);    if (!first) {    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop();