miasm
Reverse engineering framework
miasm.expression.parser Namespace Reference

Functions

def parse_loc_key (t)
 
def str_to_expr (str_in)
 

Variables

 integer
 
 hex_word = pyparsing.Literal('0x') + pyparsing.Word(pyparsing.hexnums)
 
 hex_int
 
tuple str_int_pos = (hex_int | integer)
 
tuple str_int_neg
 
tuple str_int = str_int_pos | str_int_neg
 
 STR_EXPRINT = pyparsing.Suppress("ExprInt")
 
 STR_EXPRID = pyparsing.Suppress("ExprId")
 
 STR_EXPRLOC = pyparsing.Suppress("ExprLoc")
 
 STR_EXPRSLICE = pyparsing.Suppress("ExprSlice")
 
 STR_EXPRMEM = pyparsing.Suppress("ExprMem")
 
 STR_EXPRCOND = pyparsing.Suppress("ExprCond")
 
 STR_EXPRCOMPOSE = pyparsing.Suppress("ExprCompose")
 
 STR_EXPROP = pyparsing.Suppress("ExprOp")
 
 STR_EXPRASSIGN = pyparsing.Suppress("ExprAssign")
 
 LOCKEY = pyparsing.Suppress("LocKey")
 
 STR_COMMA = pyparsing.Suppress(",")
 
 LPARENTHESIS = pyparsing.Suppress("(")
 
 RPARENTHESIS = pyparsing.Suppress(")")
 
 T_INF = pyparsing.Suppress("<")
 
 T_SUP = pyparsing.Suppress(">")
 
 string_quote = pyparsing.QuotedString(quoteChar="'", escChar='\\', escQuote='\\')
 
 string_dquote = pyparsing.QuotedString(quoteChar='"', escChar='\\', escQuote='\\')
 
 string = string_quote | string_dquote
 
 expr = pyparsing.Forward()
 
tuple expr_int = STR_EXPRINT + LPARENTHESIS + str_int + STR_COMMA + str_int + RPARENTHESIS
 
tuple expr_id = STR_EXPRID + LPARENTHESIS + string + STR_COMMA + str_int + RPARENTHESIS
 
tuple expr_loc = STR_EXPRLOC + LPARENTHESIS + T_INF + LOCKEY + str_int + T_SUP + STR_COMMA + str_int + RPARENTHESIS
 
tuple expr_slice = STR_EXPRSLICE + LPARENTHESIS + expr + STR_COMMA + str_int + STR_COMMA + str_int + RPARENTHESIS
 
tuple expr_mem = STR_EXPRMEM + LPARENTHESIS + expr + STR_COMMA + str_int + RPARENTHESIS
 
 expr_cond = STR_EXPRCOND + LPARENTHESIS + expr + STR_COMMA + expr + STR_COMMA + expr + RPARENTHESIS
 
 expr_compose = STR_EXPRCOMPOSE + LPARENTHESIS + pyparsing.delimitedList(expr, delim=',') + RPARENTHESIS
 
 expr_op = STR_EXPROP + LPARENTHESIS + string + STR_COMMA + pyparsing.delimitedList(expr, delim=',') + RPARENTHESIS
 
 expr_aff = STR_EXPRASSIGN + LPARENTHESIS + expr + STR_COMMA + expr + RPARENTHESIS
 

Function Documentation

◆ parse_loc_key()

def miasm.expression.parser.parse_loc_key (   t)

◆ str_to_expr()

def miasm.expression.parser.str_to_expr (   str_in)
Parse the @str_in and return the corresponoding Expression
@str_in: repr string of an Expression
Here is the caller graph for this function:

Variable Documentation

◆ expr

miasm.expression.parser.expr = pyparsing.Forward()

◆ expr_aff

miasm.expression.parser.expr_aff = STR_EXPRASSIGN + LPARENTHESIS + expr + STR_COMMA + expr + RPARENTHESIS

◆ expr_compose

miasm.expression.parser.expr_compose = STR_EXPRCOMPOSE + LPARENTHESIS + pyparsing.delimitedList(expr, delim=',') + RPARENTHESIS

◆ expr_cond

miasm.expression.parser.expr_cond = STR_EXPRCOND + LPARENTHESIS + expr + STR_COMMA + expr + STR_COMMA + expr + RPARENTHESIS

◆ expr_id

tuple miasm.expression.parser.expr_id = STR_EXPRID + LPARENTHESIS + string + STR_COMMA + str_int + RPARENTHESIS

◆ expr_int

tuple miasm.expression.parser.expr_int = STR_EXPRINT + LPARENTHESIS + str_int + STR_COMMA + str_int + RPARENTHESIS

◆ expr_loc

tuple miasm.expression.parser.expr_loc = STR_EXPRLOC + LPARENTHESIS + T_INF + LOCKEY + str_int + T_SUP + STR_COMMA + str_int + RPARENTHESIS

◆ expr_mem

tuple miasm.expression.parser.expr_mem = STR_EXPRMEM + LPARENTHESIS + expr + STR_COMMA + str_int + RPARENTHESIS

◆ expr_op

miasm.expression.parser.expr_op = STR_EXPROP + LPARENTHESIS + string + STR_COMMA + pyparsing.delimitedList(expr, delim=',') + RPARENTHESIS

◆ expr_slice

tuple miasm.expression.parser.expr_slice = STR_EXPRSLICE + LPARENTHESIS + expr + STR_COMMA + str_int + STR_COMMA + str_int + RPARENTHESIS

◆ hex_int

miasm.expression.parser.hex_int
Initial value:
1 = pyparsing.Combine(hex_word).setParseAction(lambda t:
2  int(t[0], 16))

◆ hex_word

miasm.expression.parser.hex_word = pyparsing.Literal('0x') + pyparsing.Word(pyparsing.hexnums)

◆ integer

miasm.expression.parser.integer
Initial value:
1 = pyparsing.Word(pyparsing.nums).setParseAction(lambda t:
2  int(t[0]))

◆ LOCKEY

miasm.expression.parser.LOCKEY = pyparsing.Suppress("LocKey")

◆ LPARENTHESIS

miasm.expression.parser.LPARENTHESIS = pyparsing.Suppress("(")

◆ RPARENTHESIS

miasm.expression.parser.RPARENTHESIS = pyparsing.Suppress(")")

◆ STR_COMMA

miasm.expression.parser.STR_COMMA = pyparsing.Suppress(",")

◆ STR_EXPRASSIGN

miasm.expression.parser.STR_EXPRASSIGN = pyparsing.Suppress("ExprAssign")

◆ STR_EXPRCOMPOSE

miasm.expression.parser.STR_EXPRCOMPOSE = pyparsing.Suppress("ExprCompose")

◆ STR_EXPRCOND

miasm.expression.parser.STR_EXPRCOND = pyparsing.Suppress("ExprCond")

◆ STR_EXPRID

miasm.expression.parser.STR_EXPRID = pyparsing.Suppress("ExprId")

◆ STR_EXPRINT

miasm.expression.parser.STR_EXPRINT = pyparsing.Suppress("ExprInt")

◆ STR_EXPRLOC

miasm.expression.parser.STR_EXPRLOC = pyparsing.Suppress("ExprLoc")

◆ STR_EXPRMEM

miasm.expression.parser.STR_EXPRMEM = pyparsing.Suppress("ExprMem")

◆ STR_EXPROP

miasm.expression.parser.STR_EXPROP = pyparsing.Suppress("ExprOp")

◆ STR_EXPRSLICE

miasm.expression.parser.STR_EXPRSLICE = pyparsing.Suppress("ExprSlice")

◆ str_int

tuple miasm.expression.parser.str_int = str_int_pos | str_int_neg

◆ str_int_neg

tuple miasm.expression.parser.str_int_neg
Initial value:
1 = (pyparsing.Suppress('-') + \
2  (hex_int | integer)).setParseAction(lambda t: -t[0])

◆ str_int_pos

tuple miasm.expression.parser.str_int_pos = (hex_int | integer)

◆ string

miasm.expression.parser.string = string_quote | string_dquote

◆ string_dquote

miasm.expression.parser.string_dquote = pyparsing.QuotedString(quoteChar='"', escChar='\\', escQuote='\\')

◆ string_quote

miasm.expression.parser.string_quote = pyparsing.QuotedString(quoteChar="'", escChar='\\', escQuote='\\')

◆ T_INF

miasm.expression.parser.T_INF = pyparsing.Suppress("<")

◆ T_SUP

miasm.expression.parser.T_SUP = pyparsing.Suppress(">")