pike.git / lib / modules / Parser.pmod / LR.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:1:   /* -  * $Id: module.pmod,v 1.4 2002/05/22 16:45:36 grubba Exp $ +  * $Id: module.pmod,v 1.5 2002/05/23 15:14:48 grubba Exp $    *    * A BNF-grammar in Pike.    * Compiles to a LALR(1) state-machine.    *    * Henrik Grubbström 1996-11-24    */      #pike __REAL_VERSION__      /*! LALR(1) parser generator    */    - // #pragma strict_types + #pragma strict_types      /*    * Defines    */      /* Errors during parsing */   /* Unexpected EOF */   constant ERROR_EOF= 1;   /* Syntax error in input */   constant ERROR_SYNTAX= 2;
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:390:    Kernel do_goto(int|string symbol)    {    multiset(Item) items;       if (verbose) {    werror("Performing GOTO on <%s>\n", symbol_to_string(symbol));    }       items = symbol_items[symbol];    if (items) { -  array(int) item_ids = map(sort(indices(items)->item_id), +  array(int) item_ids = [array(int)]map(sort(indices(items)->item_id),    `+, 1);    string kernel_hash = sprintf("%@4c", item_ids);       Kernel new_state = known_states[kernel_hash];       if (!new_state) {    known_states[kernel_hash] = new_state = Kernel();       foreach (indices(items), Item i) {    int|string lookahead;
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:1594:    rule_to_string(r));    }       do {    if (r->action) {    /* REDUCE */    string|function func = 0;       if (stringp(func = r->action)) {    if (action_object) { -  func = action_object[r->action]; +  func = [string|function]action_object[r->action];    if (!functionp(func)) {    if (!func) {    werror("Missing action \"%s\" in object\n",    r->action);    lr_error |= ERROR_MISSING_ACTION;    } else {    werror("Bad type (%s) for action \"%s\" in object\n",    typeof(func), r->action);    lr_error |= ERROR_BAD_ACTION_TYPE;    func = 0;
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:1616:    }    } else {    werror("Missing object for action \"%s\"\n",    r->action);    lr_error |= ERROR_NO_OBJECT;    func = 0;    }    }    if (func) {    if (sizeof(r->symbols)) { -  value_stack->push(([function]func)(@value_stack->pop(sizeof(r->symbols)))); +  value_stack->push(([function(mixed ...:mixed)]func) +  (@[array(mixed)]value_stack-> +  pop(sizeof(r->symbols))));    state = ([array(Kernel)]state_stack->pop(sizeof(r->symbols)))[0];    } else {    value_stack->push(r->action());    }    break; // Break out of the do-while.    }    }    // Default action.    if (sizeof(r->symbols)) {    if (sizeof(r->symbols) > 1) {
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:1676:    werror("Error: Empty stack at EOF!\n");    return (0);    }    } else {    werror("Error: Bad state at EOF\n");    return(value_stack->pop());    }    } else {    lr_error |= ERROR_SYNTAX;    -  werror("Error: Bad input: \""+input+"\"(\""+value+"\")\n"); +  werror("Error: Bad input: %O(%O)\n", input, value);    }    }    break; /* Break out of the inner while(1) to read more input. */    }    }    }   }