aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..3a39852
--- /dev/null
+++ b/main.go
@@ -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)
+}