|
@@ -91,6 +91,7 @@ func (p *Parser) Errors() []string {
|
|
|
// ParseProgram is the outermost parsing logic, accumulating statements in a
|
|
|
// Program instance and returning that instance once parsing is done.
|
|
|
func (p *Parser) ParseProgram() *ast.Program {
|
|
|
+ defer untrace(trace("ParseProgram"))
|
|
|
program := &ast.Program{
|
|
|
Statements: []ast.Statement{},
|
|
|
}
|
|
@@ -107,8 +108,8 @@ func (p *Parser) ParseProgram() *ast.Program {
|
|
|
|
|
|
// Return the precedence for the current token without advancing.
|
|
|
func (p *Parser) curPrecedence() int {
|
|
|
- if p, ok := precedences[p.curToken.Type]; ok {
|
|
|
- return p
|
|
|
+ if precedence, ok := precedences[p.curToken.Type]; ok {
|
|
|
+ return precedence
|
|
|
}
|
|
|
|
|
|
return LOWEST
|
|
@@ -138,6 +139,7 @@ func (p *Parser) nextToken() {
|
|
|
}
|
|
|
|
|
|
func (p *Parser) parseStatement() ast.Statement {
|
|
|
+ defer untrace(trace("parseStatement"))
|
|
|
switch p.curToken.Type {
|
|
|
case token.LET:
|
|
|
return p.parseLetStatement()
|
|
@@ -159,8 +161,8 @@ func (p *Parser) peekError(t token.TokenType) {
|
|
|
|
|
|
// Look forward for the precedence of the next token without advancing.
|
|
|
func (p *Parser) peekPrecedence() int {
|
|
|
- if p, ok := precedences[p.peekToken.Type]; ok {
|
|
|
- return p
|
|
|
+ if precedence, ok := precedences[p.peekToken.Type]; ok {
|
|
|
+ return precedence
|
|
|
}
|
|
|
|
|
|
return LOWEST
|