blob: 1c94efa4bad3063699426ef887b317851cb2bdce (
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
38
39
40
41
42
43
44
45
46
47
|
package main
import (
"fmt"
"os"
"git.thomasvoss.com/gsp/formatter"
"git.thomasvoss.com/gsp/parser"
)
func main() {
if len(os.Args) == 1 {
process("-")
}
for _, arg := range os.Args[1:] {
process(arg)
}
}
func process(filename string) {
var file *os.File
var err error
if filename == "-" {
file = os.Stdin
} else {
file, err = os.Open(filename)
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(e error) {
fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], e)
os.Exit(1)
}
|