about summary refs log tree commit diff stats
path: root/example
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2014-12-11 11:10:45 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2014-12-11 11:10:45 +0100
commit57c355814bfc83131fa63b4b54aaba0a009afd95 (patch)
tree3c70e51683768e79d0de5dcc9f750eab0806bac4 /example
parent847ba7b469db138a0d7196399e64c23ff34e4239 (diff)
parent03759804c045e68602df5ada8db12ff74d1bf784 (diff)
downloadmiasm-57c355814bfc83131fa63b4b54aaba0a009afd95.tar.gz
miasm-57c355814bfc83131fa63b4b54aaba0a009afd95.zip
Merge branch 'feature-exprrandom' of https://github.com/commial/miasm into commial-feature-exprrandom
Conflicts:
	miasm2/expression/expression_helper.py
Diffstat (limited to 'example')
-rw-r--r--example/expression/expr_random.py30
1 files changed, 30 insertions, 0 deletions
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)