package parser import ( "fmt" "os" "strings" ) var traceLevel = 0 const traceIndentPlaceholder = "\t" func indentLevel() string { return strings.Repeat(traceIndentPlaceholder, traceLevel-1) } func tracePrint(fs string) { if os.Getenv("VERBOSE") != "" { fmt.Printf("%s%s\n", indentLevel(), fs) } } func indentInc() { traceLevel++ } func indentDec() { traceLevel-- } func trace(msg string) string { indentInc() tracePrint("BEGIN " + msg) return msg } func untrace(msg string) { tracePrint("END " + msg) indentDec() }