Remove some redundant cmd/puffs/gen.go code.

This commit is contained in:
Nigel Tao committed 2017-06-18 09:26:30 +10:00
1 parent 7c85ed04f9
commit f23a80820c
2 files changed
+5 -7

No files matched your search

+3 -5
View File
@@ -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
}
+2 -2
View File
@@ -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
}