diff --git a/libbs/__init__.py b/libbs/__init__.py index 2540447..7c319d9 100644 --- a/libbs/__init__.py +++ b/libbs/__init__.py @@ -1,4 +1,4 @@ -__version__ = "3.3.0" +__version__ = "3.3.1" import logging diff --git a/libbs/api/type_parser.py b/libbs/api/type_parser.py index 145c485..4ae896f 100644 --- a/libbs/api/type_parser.py +++ b/libbs/api/type_parser.py @@ -95,13 +95,6 @@ def __init__( # hack in type parsing self._type_parser_singleton = pycparser.CParser() - self._type_parser_singleton.cparser = pycparser.ply.yacc.yacc( - module=self._type_parser_singleton, - start='parameter_declaration', - debug=False, - optimize=False, - errorlog=errorlog - ) self.ALL_TYPES = {} self.BASIC_TYPES = {} self.STDINT_TYPES = {} @@ -207,15 +200,15 @@ def extract_type_name(self, type_str: str) -> str | None: return type_name - def parse_type(self, defn, preprocess=True, predefined_types=None, arch=None) -> Optional[CType]: # pylint:disable=unused-argument + def parse_type(self, defn, predefined_types=None, arch=None) -> Optional[CType]: # pylint:disable=unused-argument """ Parse a simple type expression into a SimType >>> self.parse_type('int *') """ - return self.parse_type_with_name(defn, preprocess=preprocess, predefined_types=predefined_types, arch=arch)[0] + return self.parse_type_with_name(defn, predefined_types=predefined_types, arch=arch)[0] - def parse_type_with_name(self, defn, preprocess=True, predefined_types=None, arch=None): # pylint:disable=unused-argument + def parse_type_with_name(self, defn, predefined_types=None, arch=None): # pylint:disable=unused-argument """ Parse a simple type expression into a SimType, returning the a tuple of the type object and any associated name that might be found in the place a name would go in a type declaration. @@ -228,8 +221,8 @@ def parse_type_with_name(self, defn, preprocess=True, predefined_types=None, arc if pycparser is None: raise ImportError("Please install pycparser in order to parse C definitions") - if preprocess: - defn = re.sub(r"/\*.*?\*/", r"", defn) + defn = re.sub(r"/\*.*?\*/", r"", defn, flags=re.DOTALL) + defn = re.sub(r"//.*?$", r"", defn, flags=re.MULTILINE) failed_parse = False try: diff --git a/pyproject.toml b/pyproject.toml index 77d9a48..57a6630 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ requires-python = ">= 3.10" dependencies = [ "toml", "ply", - "pycparser", + "pycparser~=3.0", "setuptools", "prompt_toolkit", "tqdm",