Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.3.0"
__version__ = "3.3.1"


import logging
Expand Down
17 changes: 5 additions & 12 deletions libbs/api/type_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ requires-python = ">= 3.10"
dependencies = [
"toml",
"ply",
"pycparser",
"pycparser~=3.0",
"setuptools",
"prompt_toolkit",
"tqdm",
Expand Down
Loading