From 21f3d88b0f5afa6c04503b4f227065ad9886947e Mon Sep 17 00:00:00 2001 From: Vadym Slizov Date: Mon, 18 May 2020 22:36:39 +0300 Subject: [PATCH] [refactoring] update makefile --- Makefile | 12 ++++++------ cmd/php-parser/main.go | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 5f88103..6bcfbcd 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ cover: go test ./... --cover bench: - go test -benchmem -bench=. ./php5 - go test -benchmem -bench=. ./php7 + go test -benchmem -bench=. ./internal/php5 + go test -benchmem -bench=. ./internal/php7 compile: ./internal/php5/php5.go ./internal/php7/php7.go ./internal/scanner/scanner.go fmt sed -i '' -e 's/yyErrorVerbose = false/yyErrorVerbose = true/g' ./internal/php7/php7.go @@ -40,17 +40,17 @@ compile: ./internal/php5/php5.go ./internal/php7/php7.go ./internal/scanner/scan goyacc -o $@ $< cpu_pprof: - go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./php7 + go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./internal/php7 go tool pprof ./php7.test cpu.pprof mem_pprof: - go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./php7 + go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./internal/php7 go tool pprof -alloc_objects ./php7.test mem.pprof cpu_pprof_php5: - go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./php5 + go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./internal/php5 go tool pprof ./php5.test cpu.prof mem_pprof_php5: - go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./php5 + go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./internal/php5 go tool pprof -alloc_objects ./php5.test mem.prof diff --git a/cmd/php-parser/main.go b/cmd/php-parser/main.go index 9300288..06b11a2 100644 --- a/cmd/php-parser/main.go +++ b/cmd/php-parser/main.go @@ -1,9 +1,9 @@ package main import ( + "bytes" "flag" "fmt" - "github.com/z7zmey/php-parser/pkg/ast/traverser" "io/ioutil" "log" "os" @@ -13,8 +13,11 @@ import ( "github.com/pkg/profile" "github.com/yookoala/realpath" + + "github.com/z7zmey/php-parser/pkg/ast/traverser" "github.com/z7zmey/php-parser/pkg/ast/visitor" "github.com/z7zmey/php-parser/pkg/parser" + "github.com/z7zmey/php-parser/pkg/printer" ) var wg sync.WaitGroup @@ -138,14 +141,14 @@ func printerWorker(r <-chan result) { fmt.Fprintf(os.Stdout, "==> %s\n", e) } - //if *printBack { - // o := bytes.NewBuffer([]byte{}) - // p := printer.NewPrinter(o) - // p.Print(res.parser.GetRootNode()) - // - // err := ioutil.WriteFile(res.path, o.Bytes(), 0644) - // checkErr(err) - //} + if *printBack { + o := bytes.NewBuffer([]byte{}) + p := printer.NewPrinter(o) + p.Print(res.parser.GetRootNode()) + + err := ioutil.WriteFile(res.path, o.Bytes(), 0644) + checkErr(err) + } if *showResolvedNs { v := visitor.NewNamespaceResolver()