infix parsing and cleanup

This commit is contained in:
Chuck Smith
2024-01-16 21:02:07 -05:00
parent 307e01703e
commit 3d0247a7bb
4 changed files with 515 additions and 107 deletions

32
parser/parser_tracing.go Normal file
View File

@@ -0,0 +1,32 @@
package parser
import (
"fmt"
"strings"
)
var traceLevel int = 0
const traceIdentPlaceholder string = "\t"
func identLevel() string {
return strings.Repeat(traceIdentPlaceholder, traceLevel-1)
}
func tracePrint(fs string) {
fmt.Printf("%s%s\n", identLevel(), fs)
}
func incIdent() { traceLevel = traceLevel + 1 }
func decIdent() { traceLevel = traceLevel - 1 }
func trace(msg string) string {
incIdent()
tracePrint("BEGIN " + msg)
return msg
}
func untrace(msg string) {
tracePrint("END " + msg)
decIdent()
}