dissect.cstruct.parser

Module Contents

Classes

Parser

Base class for definition parsers.

TokenParser

CStyleParser

Definition parser for C-like structure syntax.

Token

TokenCollection

TokenConsumer

class dissect.cstruct.parser.Parser(cs: dissect.cstruct.cstruct)

Base class for definition parsers.

Parameters:

cs – An instance of cstruct.

cstruct
abstract parse(data: str) None

This function should parse definitions to cstruct types.

Parameters:

data – Data to parse definitions from, usually a string.

class dissect.cstruct.parser.TokenParser(cs: dissect.cstruct.cstruct, compiled: bool = True, align: bool = False)

Bases: Parser

Parameters:
  • cs – An instance of cstruct.

  • compiled – Whether structs should be compiled or not.

compiled
align
TOK
parse(data: str) None

This function should parse definitions to cstruct types.

Parameters:

data – Data to parse definitions from, usually a string.

class dissect.cstruct.parser.CStyleParser(cs: dissect.cstruct.cstruct, compiled: bool = True)

Bases: Parser

Definition parser for C-like structure syntax.

Parameters:
  • cs – An instance of cstruct

  • compiled – Whether structs should be compiled or not.

compiled
parse(data: str) None

This function should parse definitions to cstruct types.

Parameters:

data – Data to parse definitions from, usually a string.

class dissect.cstruct.parser.Token(token: str, value: str, match: re.Match)
__slots__ = ('token', 'value', 'match')
token
value
match
__eq__(other)
__ne__(other)
__repr__()
class dissect.cstruct.parser.TokenCollection
tokens: list[Token] = []
lookup: dict[str, str]
patterns: dict[str, re.Pattern]
__getattr__(attr: str)
add(regex: str, name: str) None
class dissect.cstruct.parser.TokenConsumer(tokens: list[Token])
tokens
flags = []
previous = None
__contains__(token: Token) bool
__len__() int
__repr__() str
property next: Token
consume() Token
reset_flags() None
eol() None