Skip to content

Commit 1bb3aac

Browse files
committed
Rewrite lexer and parser
1 parent a282438 commit 1bb3aac

File tree

14 files changed

+1692
-947
lines changed

14 files changed

+1692
-947
lines changed

dissect/cstruct/cstruct.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from dissect.cstruct.exceptions import ResolveError
1111
from dissect.cstruct.expression import Expression
12-
from dissect.cstruct.parser import CStyleParser, TokenParser
12+
from dissect.cstruct.parser import CStyleParser
1313
from dissect.cstruct.types import (
1414
LEB128,
1515
Array,
@@ -264,9 +264,9 @@ def load(self, definition: str, deftype: int | None = None, **kwargs) -> cstruct
264264
deftype = deftype or cstruct.DEF_CSTYLE
265265

266266
if deftype == cstruct.DEF_CSTYLE:
267-
TokenParser(self, **kwargs).parse(definition)
268-
elif deftype == cstruct.DEF_LEGACY:
269267
CStyleParser(self, **kwargs).parse(definition)
268+
else:
269+
raise ValueError(f"Unknown definition type: {deftype}")
270270

271271
return self
272272

dissect/cstruct/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ class Error(Exception):
22
pass
33

44

5+
class LexerError(Error):
6+
pass
7+
8+
59
class ParserError(Error):
610
pass
711

@@ -20,7 +24,3 @@ class ArraySizeError(Error):
2024

2125
class ExpressionParserError(Error):
2226
pass
23-
24-
25-
class ExpressionTokenizerError(Error):
26-
pass

0 commit comments

Comments
 (0)