From f23a80820cd543f3588dca1135c3f4bb4f801ae1 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 18 Jun 2017 09:26:30 +1000 Subject: [PATCH] Remove some redundant cmd/puffs/gen.go code. --- cmd/puffs/gen.go | 8 +++----- cmd/puffsfmt/main.go | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/puffs/gen.go b/cmd/puffs/gen.go index 307db854..d392d248 100644 --- a/cmd/puffs/gen.go +++ b/cmd/puffs/gen.go @@ -14,7 +14,6 @@ import ( "path/filepath" "strings" - "github.com/google/puffs/lang/ast" "github.com/google/puffs/lang/parse" "github.com/google/puffs/lang/render" "github.com/google/puffs/lang/token" @@ -72,7 +71,6 @@ func genDir(puffsRoot string, dirname string, filenames []string, langs []string // mtime is newer than all inputs and the puffs-gen-foo command. tm := &token.Map{} - files := []*ast.File(nil) buf := &bytes.Buffer{} for _, filename := range filenames { filename = filepath.Join(puffsRoot, filepath.FromSlash(dirname), filename) @@ -84,11 +82,11 @@ func genDir(puffsRoot string, dirname string, filenames []string, langs []string if err != nil { return err } - f, err := parse.Parse(tm, filename, tokens) - if err != nil { + // We don't need the AST node to pretty-print, but it's worth rejecting + // syntax errors early. This is just a parse, not a full type check. + if _, err := parse.Parse(tm, filename, tokens); err != nil { return err } - files = append(files, f) if err := render.Render(buf, tm, tokens, nil); err != nil { return err } diff --git a/cmd/puffsfmt/main.go b/cmd/puffsfmt/main.go index 0da1e2e4..b3fb4586 100644 --- a/cmd/puffsfmt/main.go +++ b/cmd/puffsfmt/main.go @@ -112,8 +112,8 @@ func do(r io.Reader, filename string) error { if err != nil { return err } - // We don't need the AST node to pretty-print, but it's worth puffsfmt - // rejecting syntax errors. This is just a parse, not a full type check. + // We don't need the AST node to pretty-print, but it's worth rejecting + // syntax errors early. This is just a parse, not a full type check. if _, err := parse.Parse(tm, filename, tokens); err != nil { return err }