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.15 2007/05/03 09:09:41 grubba Exp $ +  * $Id: module.pmod,v 1.16 2008/01/09 16:10:29 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.
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:221:   //! {parse}*   //! @}   class Parser   {    //! The grammar itself.    mapping(int : array(Rule)) grammar = ([]);       /* Priority table for terminal symbols */    static mapping(string : Priority) operator_priority = ([]);    -  static multiset(mixed) nullable = (< >); +  static multiset(int|string) nullable = (< >);      #if 0    static mapping(mixed : multiset(Rule)) derives = ([]);       /* Maps from symbol to which rules may start with that symbol */    static mapping(mixed : multiset(Rule)) begins = ([]);   #endif /* 0 */       /* Maps from symbol to the rules that use the symbol    * (used for finding nullable symbols)
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:697:    {    error_handler = handler || ErrorHandler()->report;    }       //! Add a rule to the grammar.    //!    //! @param r    //! Rule to add.    void add_rule(Rule r)    { -  array(Rule) rules; +     int|string symbol;       /* DEBUG */    report(NOTICE, "add_rule", "Adding rule: %s", rule_to_string(r));       /* !DEBUG */       r->number = next_rule_number;    /* Reserve space for the items generatable from this rule. */    next_rule_number += sizeof(r->symbols) + 1;
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:911:    if (cyclic) {    report(NOTICE, "traverse_items", "Cyclic item\n%s",    item_to_string(i));    conflict_func(empty_cycle && !(sizeof(i->error_lookahead)));    }    }    }       static void shift_conflict(int empty)    { -  /* Ignored */ +  empty; /* Ignored */    }       static void handle_shift_conflicts()    {    item_stack = ADT.Stack(131072);       /* Initialize the counter */    for (int index = 0; index < s_q->tail; index++) {    foreach (s_q->arr[index]->items, Item i) {    if ((i->offset != sizeof(i->r->symbols)) &&
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:943:    foreach (s_q->arr[index]->items, Item i) {    if (!i->number) {    traverse_items(i, shift_conflict);    }    }    }    }       static void follow_conflict(int empty)    { +  empty; /* Ignored */    }       static void handle_follow_conflicts()    {    item_stack = ADT.Stack(131072);       /* Initialize the counter */    for (int index = 0; index < s_q->tail; index++) {    foreach (s_q->arr[index]->items, Item i) {    if ((i->offset != sizeof(i->r->symbols)) &&
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:975:    if (!i->number) {    traverse_items(i, follow_conflict);    }    }    }    }       static int go_through(Kernel state, int item_id,    Item current_item)    { -  int index; +     Item i, master;       i = state->item_id_to_item[item_id];       /* What to do if not found? */    if (!i) {    report(ERROR, "go_through",    "Item %d not found in state\n"    "%s\n"    "Backtrace:\n%s",