From 5cb14ef013c9d4000c6676f1da9b45d268948abf Mon Sep 17 00:00:00 2001 From: wmin0 Date: Tue, 22 Jan 2019 17:43:50 +0800 Subject: 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 --- core/vm/sqlvm/cmd/ast-printer/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'core/vm/sqlvm/cmd') 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) } } -- cgit v1.2.3