From d443b2736344ae0ff6f9dc4b933dd0c86966b7a6 Mon Sep 17 00:00:00 2001 From: Erik Soma Date: Mon, 25 Jul 2016 19:58:54 -0400 Subject: Allow user to decide which lexer the parser uses. --- pycparser/c_parser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py index 5c17a74..d02e577 100644 --- a/pycparser/c_parser.py +++ b/pycparser/c_parser.py @@ -20,6 +20,7 @@ class CParser(PLYParser): def __init__( self, lex_optimize=True, + lexer=CLexer, lextab='pycparser.lextab', yacc_optimize=True, yacctab='pycparser.yacctab', @@ -41,7 +42,11 @@ class CParser(PLYParser): When releasing with a stable lexer, set to True to save the re-generation of the lexer table on each run. - + + lexer: + Set this parameter to define the lexer to use if + you're not using the default CLexer. + lextab: Points to the lex table that's used for optimized mode. Only if you're modifying the lexer and want @@ -70,7 +75,7 @@ class CParser(PLYParser): Set this parameter to control the location of generated lextab and yacctab files. """ - self.clex = CLexer( + self.clex = lexer( error_func=self._lex_error_func, on_lbrace_func=self._lex_on_lbrace_func, on_rbrace_func=self._lex_on_rbrace_func, -- cgit v1.2.1