-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (31 loc) · 932 Bytes
/
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
package main
import (
"Leafscript/supporting"
"fmt"
"os"
"strings"
"github.com/akamensky/argparse"
)
func main() {
// create argparse
parser := argparse.NewParser("Leafscript", "The interpreter of the Leafscript programming language")
run := parser.String("r", "run", &argparse.Options{Help: "The path to the .lfs file to run"})
debug := parser.Flag("d", "debug", &argparse.Options{Default: false, Help: "Include to run program in debug mode"})
err := parser.Parse(os.Args)
if err != nil {
fmt.Println(parser.Usage(err))
}
// ensure correct file format is used
if strings.Contains(*run, ".lfs") {
// parse file to language
fileLines := supporting.ParseFile(*run)
if *debug {
supporting.Lex(fileLines, true)
} else {
supporting.Lex(fileLines, false)
}
} else {
fmt.Println("Invalid file format. Please use the format .lfs")
fmt.Println("To view usage information, include the -h flag")
}
}