Skip to content

Commit

Permalink
clean up codes
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 10, 2024
1 parent 48750bb commit 3da9ce9
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ import (
"github.com/JunNishimura/go-lisp/token"
)

// const (
// _ int = iota
// LOWEST
// SUM // +
// PRODUCT // *
// )

// type (
// prefixParseFn func() ast.Expression
// )

type Parser struct {
l *lexer.Lexer

Expand All @@ -38,13 +27,6 @@ func New(l *lexer.Lexer) *Parser {
p.nextToken()
p.nextToken()

// p.prefixParseFns = make(map[token.TokenType]prefixParseFn)
// p.registerPrefix(token.INT, p.parseIntegerLiteral)
// p.registerPrefix(token.PLUS, p.parsePrefixExpression)
// p.registerPrefix(token.MINUS, p.parsePrefixExpression)
// p.registerPrefix(token.ASTERISK, p.parsePrefixExpression)
// p.registerPrefix(token.SLASH, p.parsePrefixExpression)

return p
}

Expand All @@ -64,25 +46,11 @@ func (p *Parser) curError(types ...token.TokenType) {
p.errors = append(p.errors, msg)
}

func (p *Parser) peekError(t token.TokenType) {
msg := fmt.Sprintf("expected next token to be %s, got %s instead", t, p.peekToken.Type)
p.errors = append(p.errors, msg)
}

func (p *Parser) nextToken() {
p.curToken = p.peekToken
p.peekToken = p.l.NextToken()
}

func (p *Parser) expectPeek(t token.TokenType) bool {
if p.peekTokenIs(t) {
p.nextToken()
return true
}
p.peekError(t)
return false
}

func (p *Parser) expectCur(t token.TokenType) bool {
if p.curTokenIs(t) {
p.nextToken()
Expand Down Expand Up @@ -200,7 +168,3 @@ func (p *Parser) isOperator() bool {
func (p *Parser) curTokenIs(t token.TokenType) bool {
return p.curToken.Type == t
}

func (p *Parser) peekTokenIs(t token.TokenType) bool {
return p.peekToken.Type == t
}

0 comments on commit 3da9ce9

Please sign in to comment.