aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-12 12:13:42 +0800
committerobscuren <geffobscura@gmail.com>2014-04-12 12:13:42 +0800
commit086acd122b59071255b0c1cfae569748b1d7427a (patch)
tree6ff564b1720298085ad89de53a2b4e4f0db21ca7 /ethutil
parent116516158da637cde50d27d600db6661732fc402 (diff)
downloaddexon-086acd122b59071255b0c1cfae569748b1d7427a.tar
dexon-086acd122b59071255b0c1cfae569748b1d7427a.tar.gz
dexon-086acd122b59071255b0c1cfae569748b1d7427a.tar.bz2
dexon-086acd122b59071255b0c1cfae569748b1d7427a.tar.lz
dexon-086acd122b59071255b0c1cfae569748b1d7427a.tar.xz
dexon-086acd122b59071255b0c1cfae569748b1d7427a.tar.zst
dexon-086acd122b59071255b0c1cfae569748b1d7427a.zip
Added pre processing of script data
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/parsing.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/ethutil/parsing.go b/ethutil/parsing.go
index 278414982..328704cae 100644
--- a/ethutil/parsing.go
+++ b/ethutil/parsing.go
@@ -3,6 +3,7 @@ package ethutil
import (
_ "fmt"
"math/big"
+ "regexp"
)
// Op codes
@@ -132,3 +133,33 @@ func Assemble(instructions ...interface{}) (script []byte) {
return
}
+
+/*
+Prepocessing function that takes init and main apart:
+init() {
+ // something
+}
+
+main() {
+ // main something
+}
+*/
+func PreProcess(data string) (mainInput, initInput string) {
+ reg := "\\(\\)\\s*{([\\d\\w\\W\\n\\s]+?)}"
+ mainReg := regexp.MustCompile("main" + reg)
+ initReg := regexp.MustCompile("init" + reg)
+
+ main := mainReg.FindStringSubmatch(data)
+ if len(main) > 0 {
+ mainInput = main[1]
+ } else {
+ mainInput = data
+ }
+
+ init := initReg.FindStringSubmatch(data)
+ if len(init) > 0 {
+ initInput = init[1]
+ }
+
+ return
+}