Download and add the "code" folder.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
4d018b4ceb
commit
9aa807b9c2
55 changed files with 9090 additions and 0 deletions
32
waiig_code_1.7/04/src/monkey/parser/parser_tracing.go
Normal file
32
waiig_code_1.7/04/src/monkey/parser/parser_tracing.go
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue