diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-09-02 18:49:53 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-09-08 23:16:19 +0200 |
commit | 643623dbecdc1ccb6f3ac77e4ebabdc6ca1d8d06 (patch) | |
tree | a9d6b50ad7263e792bc276f765ada74a5661a8b1 /main.go |
Genesis commit
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "os" + + "git.thomasvoss.com/gsp/formatter" + "git.thomasvoss.com/gsp/parser" +) + +func main() { + if len(os.Args) != 2 { + fmt.Fprintf(os.Stderr, "Usage: %s file\n", os.Args[0]) + os.Exit(1) + } + file, err := os.Open(os.Args[1]) + if err != nil { + die(err) + } + defer file.Close() + ast, err := parser.ParseFile(file) + if err != nil { + die(err) + } + + formatter.PrintHtml(ast) + fmt.Print("\n") +} + +func die(strings ...any) { + fmt.Fprint(os.Stderr, os.Args[0]) + for _, s := range strings { + fmt.Fprintf(os.Stderr, ": %v", s) + } + fmt.Fprint(os.Stderr, "\n") + os.Exit(1) +} |