runningwater 3 years ago
parent
commit
4c56a9b142
3 changed files with 6 additions and 5 deletions
  1. 0 1
      lexer/lexer_test.go
  2. 2 0
      parser/parser.go
  3. 4 4
      parser/parser_tracing.go

+ 0 - 1
lexer/lexer_test.go

@@ -1,7 +1,6 @@
 package lexer
 
 import (
-	"github/runnignwater/monkey/ast"
 	"github/runnignwater/monkey/token"
 	"testing"
 )

+ 2 - 0
parser/parser.go

@@ -108,6 +108,7 @@ func (p *Parser) parseGroupedExpression() ast.Expression {
 	return exp
 }
 func (p *Parser) parseIfExpression() ast.Expression {
+	defer untrace(trace("parseIfExpression"))
 	exp := &ast.IfExpression{Token: p.curToken}
 
 	// (
@@ -182,6 +183,7 @@ func (p *Parser) parsePrefixExpression() ast.Expression {
 	return exp
 }
 func (p *Parser) parseBlockStatement() *ast.BlockStatement {
+	defer untrace(trace("parseBlockStatement"))
 	block := &ast.BlockStatement{Token: p.curToken}
 	block.Statements = []ast.Statement{}
 

+ 4 - 4
parser/parser_tracing.go

@@ -21,12 +21,12 @@ func incIdent() { traceLevel = traceLevel + 1 }
 func decIdent() { traceLevel = traceLevel - 1 }
 
 func trace(msg string) string {
-	//incIdent()
-	//tracePrint("BEGIN " + msg)
+	incIdent()
+	tracePrint("BEGIN " + msg)
 	return msg
 }
 
 func untrace(msg string) {
-	//tracePrint("END " + msg)
-	//decIdent()
+	tracePrint("END " + msg)
+	decIdent()
 }