dissect.cstruct.expression#

Module Contents#

Classes#

ExpressionTokenizer

Expression

Expression parser for calculations in definitions.

Attributes#

dissect.cstruct.expression.HEXBIN_SUFFIX#
class dissect.cstruct.expression.ExpressionTokenizer(expression: str)#
equal(token: str, expected: str | str[str]) bool#
alnum(token: str) bool#
alpha(token: str) bool#
digit(token: str) bool#
hexdigit(token: str) bool#
operator(token: str) bool#
match(func: Callable[[str], bool] | None = None, expected: str | None = None, consume: bool = True, append: bool = True) bool#
consume() None#
eol() bool#
get_token() str#
tokenize() list[str]#
class dissect.cstruct.expression.Expression(cstruct: Expression.__init__.cstruct, expression: str)#

Expression parser for calculations in definitions.

operators#
precedence_levels#
__repr__() str#

Return repr(self).

precedence(o1: str, o2: str) bool#
evaluate_exp() None#
is_number(token: str) bool#
evaluate(context: dict[str, int] | None = None) int#

Evaluates an expression using a Shunting-Yard implementation.