summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2025-01-07 00:30:49 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-01-07 00:30:49 +0400
commit4ebd6ed7b4a86f2e35f2295a134e1227a6b46c58 (patch)
tree8b9cd9c345be7fe7f7d1c19674f65fb36dd79287
parent9273084882cf7a90f7010b6747c4668fb610330f (diff)
specify the type of in error messages with err
-rw-r--r--src/main.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.go b/src/main.go
index e6676ef..acc275b 100644
--- a/src/main.go
+++ b/src/main.go
@@ -596,27 +596,33 @@ func main() {
fmt.Fprintf(os.Stderr, "%s: error: expected one input file.\n", progname)
os.Exit(1)
}
+
srcFile := argv[argc - 1]
if !strings.HasSuffix(srcFile, suffix) || len(srcFile) < 7 {
fmt.Fprintf(os.Stderr, "%s: error: invalid file format '%s'.\n", progname, srcFile)
os.Exit(1)
}
+
+ assemFile := srcFile[:len(srcFile) - 6] + ".s"
+ // binFile := srcFile[:len(srcFile) - 6]
_, err := os.Stat(srcFile)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: error: %s.\n", progname, err)
os.Exit(1)
}
- assemFile := srcFile[:len(srcFile) - 6] + ".s"
file, err := os.Create(assemFile)
if err != nil {
- fmt.Fprintf(os.Stderr, "%s: error: failed create output file '%s'.\n", progname, file)
+ fmt.Fprintf(os.Stderr, "%s: error: %s.\n", progname, err)
os.Exit(1)
}
tokens := tokenize(argv[argc - 1])
tokens = preprocess(tokens)
ops := parse(tokens)
- /* FIXME: check for error */
w := bufio.NewWriter(file)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%s: error: %s.\n", progname, err)
+ os.Exit(1)
+ }
generateX86_64(ops, w)
w.Flush()
}