diff options
author | wmin0 <wmin0@cobinhood.com> | 2019-01-22 17:43:50 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-03-26 17:48:21 +0800 |
commit | 5cb14ef013c9d4000c6676f1da9b45d268948abf (patch) | |
tree | 3c1dbec922e9c0e5d63092be0a99bb5b64df9194 /core/vm/sqlvm/cmd | |
parent | f8f20fdb02525ac5bbaf129cfe29b987c563ef9f (diff) | |
download | dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.tar dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.tar.gz dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.tar.bz2 dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.tar.lz dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.tar.xz dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.tar.zst dexon-5cb14ef013c9d4000c6676f1da9b45d268948abf.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) } } |