def __init__( self, app=None, style=None, lex_optimize=False, lextab='zwiki.lextab', lex_debug=False, yacc_optimize=False, yacctab='zwiki.yacctab', yacc_debug=False, ): """Create a new ZWParser. Some arguments for controlling the debug/optimization level of the parser are provided. The defaults are tuned for release/performance mode. The simple rules for using them are: *) When tweaking ZWParser/ZWLexer, set these to False *) When releasing a stable parser, set to True app: Application object that provides the standard objects to be used by ZWiki. name should indicate the application name. Supported applications are, 'zeta' For more information refer to the ZWiki documentation. style: A dictionary containing CSS styling properties. When available, it will be used instead of the default `wiki_css` property. lex_optimize: Set to False when you're modifying the lexer. Otherwise, changes in the lexer won't be used, if some lextab.py file exists. When releasing with a stable lexer, set to True to save the re-generation of the lexer table on each run. lextab: Points to the lex table that's used for optimized mode. Only if you're modifying the lexer and want some tests to avoid re-generating the table, make this point to a local lex table file (that's been earlier generated with lex_optimize=True) yacc_optimize: Set to False when you're modifying the parser. Otherwise, changes in the parser won't be used, if some parsetab.py file exists. When releasing with a stable parser, set to True to save the re-generation of the parser table on each run. yacctab: Points to the yacc table that's used for optimized mode. Only if you're modifying the parser, make this point to a local yacc table file. yacc_debug: Generate a parser.out file that explains how yacc built the parsing table from the grammar.""" self.app = app self.zwlex = ZWLexer(error_func=self._lex_error_func) self.zwlex.build(optimize=lex_optimize, lextab=lextab, debug=lex_debug) self.tokens = self.zwlex.tokens self.parser = ply.yacc.yacc(module=self, debug=yacc_debug, optimize=yacc_optimize, tabmodule=yacctab) self.parser.zwparser = self self.style = style self.debug = lex_debug or yacc_debug