diff options
author | wmin0 <wmin0@cobinhood.com> | 2019-01-22 17:43:50 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-05-06 10:44:03 +0800 |
commit | d07af9fe6ba1299bec081b77d575d31a23a2f6e1 (patch) | |
tree | bb9fc3ae1aa0b3674a65174fe9812b3a97903c06 /core/vm/sqlvm/cmd | |
parent | d25ee5f726545b165dba6a45def0e55027b6941b (diff) | |
download | dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.tar dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.tar.gz dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.tar.bz2 dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.tar.lz dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.tar.xz dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.tar.zst dexon-d07af9fe6ba1299bec081b77d575d31a23a2f6e1.zip |
core: vm: sqlvm: remove optional interface and add print tag for detail
There are some changes in print ast utility.
1. instead of using optional interface to get detail, use reflect
2. implement a `print` field tag for printer switching detail mode or
not
Diffstat (limited to 'core/vm/sqlvm/cmd')
-rw-r--r-- | core/vm/sqlvm/cmd/ast-printer/main.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/vm/sqlvm/cmd/ast-printer/main.go b/core/vm/sqlvm/cmd/ast-printer/main.go index 4911273c5..200f47173 100644 --- a/core/vm/sqlvm/cmd/ast-printer/main.go +++ b/core/vm/sqlvm/cmd/ast-printer/main.go @@ -1,17 +1,23 @@ package main import ( + "flag" "fmt" - "os" "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" "github.com/dexon-foundation/dexon/core/vm/sqlvm/parser" ) func main() { - n, err := parser.ParseString(os.Args[1]) + var detail bool + flag.BoolVar(&detail, "detail", false, "print struct detail") + + flag.Parse() + + n, err := parser.ParseString(flag.Arg(0)) + fmt.Printf("detail: %t\n", detail) fmt.Printf("err: %+v\n", err) if err == nil { - ast.PrintAST(n, "") + ast.PrintAST(n, "", detail) } } |