diff options
-rw-r--r-- | src/texec/worldbuilder.go | 34 | ||||
-rw-r--r-- | src/tint.go | 2 |
2 files changed, 29 insertions, 7 deletions
diff --git a/src/texec/worldbuilder.go b/src/texec/worldbuilder.go index 69be803..39a0e12 100644 --- a/src/texec/worldbuilder.go +++ b/src/texec/worldbuilder.go @@ -21,6 +21,10 @@ import ( "fmt" ) +var ( + Quiet = false +) + /** worldbuilder.go - take in a file name and construct a root TModule based on it. */ @@ -100,7 +104,11 @@ func modDefStruct(n tparse.Node, m *TModule) { func modDefEnum(n tparse.Node, m *TModule) { name := n.Sub[0].Data.Data t := getType(n.Sub[1]) - fmt.Println(t) + + if !Quiet { + fmt.Println(t) + } + s, vs := modDefVars(n.Sub[2], t) out := TVariable{tEnum, make(VarMap)} for i := 0; i < len(s); i++ { @@ -117,7 +125,9 @@ func parseFile(p string) tparse.Node { // Import a file and auto-import sub-modules and files func importFile(f string, m *TModule) { - fmt.Printf("[INFO] Importing file %s\n", f) + if !Quiet { + fmt.Printf("[INFO] Importing file %s\n", f) + } froot := parseFile(f) for n := 0 ; n < len(froot.Sub) ; n++ { if froot.Sub[n].Data.Data == "block" { @@ -127,7 +137,9 @@ func importFile(f string, m *TModule) { m.Artifacts = append(m.Artifacts, froot.Sub[n]) } } else if froot.Sub[n].Data.Data == "include" { - fmt.Printf("[INCLUDE] %s\n", evalPreLiteral(froot.Sub[n].Sub[0])) + if !Quiet { + fmt.Printf("[INCLUDE] %s\n", evalPreLiteral(froot.Sub[n].Sub[0])) + } importFile(evalPreLiteral(froot.Sub[n].Sub[0]), m) } else if froot.Sub[n].Data.Data == "define" { modDef(froot.Sub[n], m) @@ -140,7 +152,9 @@ func importFile(f string, m *TModule) { } } - fmt.Printf("[INFO] File %s has been imported.\n", f) + if !Quiet { + fmt.Printf("[INFO] File %s has been imported.\n", f) + } } // Build a module from a module block node @@ -153,16 +167,22 @@ func buildModule(module tparse.Node) TModule { out.Name = module.Sub[0].Sub[0].Sub[0].Data.Data } - fmt.Printf("[INFO] Found module %s\n", out.Name) + if !Quiet { + fmt.Printf("[INFO] Found module %s\n", out.Name) + } for n := 1 ; n < len(module.Sub) ; n++ { if module.Sub[n].Data.Data == "include" { - fmt.Printf("[INCLUDE] %s\n", evalPreLiteral(module.Sub[n].Sub[0])) + if !Quiet { + fmt.Printf("[INCLUDE] %s\n", evalPreLiteral(module.Sub[n].Sub[0])) + } importFile(evalPreLiteral(module.Sub[n].Sub[0]), &out) } } - fmt.Printf("[INFO] Finished loading module %s\n", out.Name) + if !Quiet { + fmt.Printf("[INFO] Finished loading module %s\n", out.Name) + } return out } diff --git a/src/tint.go b/src/tint.go index b17d8b0..b2566b5 100644 --- a/src/tint.go +++ b/src/tint.go @@ -23,9 +23,11 @@ import "flag" func main() { inputFile := flag.String("in", "", "The file to execute") progFlags := flag.String("flags", "", "Flags for the executing program") + quietFlag := flag.Bool("quiet", false, "Quiet the interpreter when importing files") flag.Parse() + texec.Quiet = *quietFlag root := texec.BuildRoot(*inputFile) fmt.Printf("Program end. Returned %v.\n", texec.EvalTNSL(&root, *progFlags)) |