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.6 2002/05/24 12:53:15 grubba Exp $ +  * $Id: module.pmod,v 1.7 2002/05/24 14:36:28 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:235:    //! Error code    int lr_error=0;       /* Number of next rule (used only for conflict resolving) */    static int next_rule_number = 1;       //! LR0 states that are already known to the compiler.    mapping(string:Kernel) known_states = ([]);       //! Compile error and warning handler. -  ErrorHandler error_handler = ErrorHandler(); +  function(SeverityLevel, string, string, mixed ...:void) error_handler = +  ErrorHandler()->report;       void report(SeverityLevel level, string subsystem, string msg,    mixed ... args)    {    if (!error_handler) { -  error_handler = ErrorHandler(); +  error_handler = ErrorHandler()->report;    } -  error_handler->report(level, subsystem, msg, @args); +  error_handler(level, subsystem, msg, @args);    }       /*    * Sub-classes    */       //!    //! An LR(0) item, a partially parsed rule.    //!    static class Item
pike.git/lib/modules/Parser.pmod/LR.pmod/module.pmod:665:       //! Sets the symbol to string conversion function.    //! The conversion function is used by the various *_to_string functions    //! to make comprehensible output.    //!    //! @param s_to_s    //! Symbol to string conversion function.    //! If zero or not specified, use the built-in function.    void set_symbol_to_string(void|function(int|string:string) s_to_s)    { -  if (s_to_s) { -  symbol_to_string = s_to_s; -  } else { -  symbol_to_string = builtin_symbol_to_string; +  symbol_to_string = s_to_s || builtin_symbol_to_string;    } -  +  +  //! Sets the error report function. +  //! +  //! @param handler +  //! Function to call to report errors and warnings. +  //! If zero or not specifier, use the built-in function. +  void set_error_handler(void|function(SeverityLevel, string, string, mixed ...: void) handler) +  { +  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;