From 03759804c045e68602df5ada8db12ff74d1bf784 Mon Sep 17 00:00:00 2001 From: Camille Mougey Date: Wed, 10 Dec 2014 17:28:33 +0100 Subject: Example: Add an example for ExprRandom --- example/expression/expr_random.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 example/expression/expr_random.py (limited to 'example/expression/expr_random.py') diff --git a/example/expression/expr_random.py b/example/expression/expr_random.py new file mode 100644 index 00000000..1d399091 --- /dev/null +++ b/example/expression/expr_random.py @@ -0,0 +1,30 @@ +import string + +from miasm2.expression.expression_helper import ExprRandom + +print "Simple expression generator\n" + +depth = 8 +print "- An ID:" +print ExprRandom.identifier() +print "- A number:" +print ExprRandom.number() + +print "- 3 expressions (without cleaning expression cache):" +for i in xrange(3): + print "\t%s\n" % ExprRandom.get(depth=depth, clean=False) + +class ExprRandom_NoPerfect_NoReuse_UppercaseIdent(ExprRandom): + """ExprRandom extension with: + - perfect tree disabled + - element reuse disabled + - identifiers uppercased + """ + + perfect_tree = False + reuse_element = False + identifier_charset = string.uppercase + +print "- 3 expressions with a custom generator:" +for i in xrange(3): + print "\t%s\n" % ExprRandom_NoPerfect_NoReuse_UppercaseIdent.get(depth=depth) -- cgit 1.4.1