def __init__(self, options): self.preprocessor_parser = preprocessor.PreprocessorParser( options, self) self.parser = yacc.Parser() prototype = yacc.yacc(method='LALR', debug=False, module=cgrammar, write_tables=True, outputdir=os.path.dirname(__file__), optimize=True) # If yacc is reading tables from a file, then it won't find the error # function... need to set it manually prototype.errorfunc = cgrammar.p_error prototype.init_parser(self.parser) self.parser.cparser = self self.lexer = CLexer(self) if not options.no_stddef_types: self.lexer.type_names.add('wchar_t') self.lexer.type_names.add('ptrdiff_t') self.lexer.type_names.add('size_t') if not options.no_gnu_types: self.lexer.type_names.add('__builtin_va_list') if sys.platform == 'win32' and not options.no_python_types: self.lexer.type_names.add('__int64')
def __init__(self, stddef_types=True, gnu_types=True, cache_headers=True): self.preprocessor_parser = CPreprocessorParser(self) self.parser = yacc.Parser() yacc.yacc(method='LALR').init_parser(self.parser) self.parser.cparser = self self.lexer = CLexer(self) if stddef_types: self.lexer.type_names.add('wchar_t') self.lexer.type_names.add('ptrdiff_t') self.lexer.type_names.add('size_t') if gnu_types: self.lexer.type_names.add('__builtin_va_list') if sys.platform == 'win32': self.lexer.type_names.add('__int64') self.header_cache = {} self.cache_headers = cache_headers self.load_header_cache()