blob: 3a3985216badd4b048bc9a6e706ce285c073b406 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)
}
|