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

version» Context lines:

pike.git/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod:25:   //! symbol : "string" ;   //! action : "{" "identifier" "}" ;   //! nonterminal : "identifier" ;   //! terminal : "string";   //! @}      /*    * Defines    */    - /* #define DEBUG */ + /* #define LR_DEBUG */      /* Errors during parsing */   /* Action for rule is missing from master object */   #define ERROR_MISSING_ACTION 256   /* Action for rule is not a function */   #define ERROR_BAD_ACTION 512      import Parser.LR;      protected private Parser _parser = Parser();
pike.git/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod:170:   protected private object master;      //! Error code from the parsing.   int lr_error;      protected private int add_nonterminal(string id)   {    int nt = nonterminal_lookup[id];       if (!nt) { -  nt = nonterminal_lookup[id] = id_stack->ptr; +  nt = nonterminal_lookup[id] = sizeof(id_stack);    id_stack->push(id);    }    return nt;   }      protected private void add_tokens(array(string) tokens)   {    /* NOOP */   #if 0    if (sizeof(tokens)) {
pike.git/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod:205:   {    if (intp(symbol))    return nonterminals[symbol];    else    return "\"" + symbol + "\"";   }      protected private string symbol_to_string(int|string symbol)   {    if (intp(symbol)) { -  if (symbol < id_stack->ptr) -  return id_stack->arr[symbol]; +  if (symbol < sizeof(id_stack)) +  return values(id_stack)[symbol];    else    /* Only happens with the initial(automatic) rule */    return "nonterminal"+symbol;    } else    return "\""+symbol+"\"";   }      protected private void add_rule(int nt, string colon, array(mixed) symbols, string action)   {    if (action == ";") {
pike.git/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod:317:    scanner->str = str;    scanner->pos = 0;       g->set_symbol_to_string(symbol_to_string);       id_stack = ADT.Stack();       nonterminal_lookup = ([]);       ErrorHandler eh = ErrorHandler( - #ifdef DEBUG + #ifdef LR_DEBUG    1 - #else /* !DEBUG */ + #else /* !LR_DEBUG */    0 - #endif /* DEBUG */ + #endif /* LR_DEBUG */    );    - #ifdef DEBUG + #ifdef LR_DEBUG    _parser->set_error_handler(eh->report); - #endif /* DEBUG */ + #endif /* LR_DEBUG */       g->set_error_handler(eh->report);       /* Default rule -- Will never be reduced */    id_stack->push("Translation Unit"); /* Nonterminal #0 -- Start symbol */    g->add_rule(Rule(0, ({ 1, "" }), 0)); /* Rule #0 -- Start rule */       _parser->parse(scanner->scan);       if ((!_parser->lr_error) &&