-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
executable file
·43 lines (36 loc) · 1.01 KB
/
main.go
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
//go:generate go get golang.org/x/tools/cmd/goyacc
//go:generate goyacc -o parser/parser.go -v parser/y.output parser/parser.y
//go:generate goyacc -o builtins_parser/builtins_parser.go -p builtins -v builtins_parser/y.output builtins_parser/builtins_parser.y
//go:generate go build -o lsl_ext
package main
import (
"fmt"
"os"
"./builtins_parser"
"./parser"
)
// TODO: add commang line arguments and options
func main() {
builtins, err := builtins_parser.ParseBuiltins()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for _, arg := range os.Args[1:] {
script, err := parser.ParseFile(arg)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
script.Builtins = builtins
script.ConnectTree()
if len(script.Errors) == 0 {
fmt.Printf("%s\n\n", script)
} else {
for _, err := range script.Errors {
fmt.Printf("%s %s\n", err.At, err.Error)
}
os.Exit(1)
}
}
}