diff options
author | Erik Soma <stillusingirc@gmail.com> | 2016-07-25 19:58:54 -0400 |
---|---|---|
committer | Erik Soma <stillusingirc@gmail.com> | 2016-07-25 19:58:54 -0400 |
commit | d443b2736344ae0ff6f9dc4b933dd0c86966b7a6 (patch) | |
tree | 872414ce4bf3900d5f3c4ca60c301937d1607cff | |
parent | ffd8cb7dfc4b80c79a500e27736db8f7bfc1186e (diff) | |
download | pycparser-d443b2736344ae0ff6f9dc4b933dd0c86966b7a6.tar.gz |
Allow user to decide which lexer the parser uses.
-rw-r--r-- | pycparser/c_parser.py | 9 |
1 files 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, |