-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
executable file
·50 lines (41 loc) · 886 Bytes
/
main.go
File metadata and controls
executable file
·50 lines (41 loc) · 886 Bytes
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
48
49
50
package main
import (
"fmt"
"os"
"sulfur/src/settings"
"sulfur/src/sulfurc"
"sulfur/src/utils"
"time"
)
func main() {
start := time.Now()
args := utils.NewQueue(os.Args[1:])
mode := args.AttemptNext("No mode given")
input := args.AttemptNext("No file given")
output := utils.FileName(input)
for !args.Empty() {
name := *args.Consume()
if name[0] == '-' { // Is a flag
switch name[1:] {
case "trace":
settings.Stacktrace = true
case "debug":
settings.Debug = true
case "colorless":
settings.Colored = false
case "o":
if arg, ok := args.Next(); ok {
output = *arg
} else {
utils.Panic("No output file given")
}
}
}
}
name := utils.FileName(input)
sulfurc.Clear()
sulfurc.SetMode(mode)
sulfurc.Compile(name, input, output)
fmt.Println("Compile time:", time.Since(start))
sulfurc.Execute(name, output)
}