Skip to content

Commit

Permalink
removing the stpd tests!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonak-Adipta-Kalita committed Apr 8, 2023
1 parent 878af17 commit 7d6f6c7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 576 deletions.
28 changes: 0 additions & 28 deletions ast/ast_test.go

This file was deleted.

51 changes: 0 additions & 51 deletions lexer/lexer_test.go

This file was deleted.

20 changes: 15 additions & 5 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ func New(l *lexer.Lexer) *Parser {
errors: []string{},
}

p.nextToken()
p.nextToken()

p.prefixParseFns = make(map[token.TokenType]prefixParseFn)
p.registerPrefix(token.IDENTIFIER, p.parseIdentifier)
p.registerPrefix(token.INT, p.parseIntegerLiteral)
p.registerPrefix(token.BANG, p.parsePrefixExpression)
p.registerPrefix(token.MINUS, p.parsePrefixExpression)
p.registerPrefix(token.TRUE, p.parseBoolean)
p.registerPrefix(token.FALSE, p.parseBoolean)

p.infixParseFns = make(map[token.TokenType]infixParseFn)
p.registerInfix(token.PLUS, p.parseInfixExpression)
Expand All @@ -72,8 +71,10 @@ func New(l *lexer.Lexer) *Parser {
p.registerInfix(token.LT, p.parseInfixExpression)
p.registerInfix(token.GT, p.parseInfixExpression)

p.registerPrefix(token.TRUE, p.parseBoolean)
p.registerPrefix(token.FALSE, p.parseBoolean)
p.registerPrefix(token.LPAREN, p.parseGroupedExpression)

p.nextToken()
p.nextToken()

return p
}
Expand All @@ -98,6 +99,15 @@ func (p *Parser) parseBoolean() ast.Expression {
return &ast.Boolean{Token: p.curToken, Value: p.curTokenIs(token.TRUE)}
}

func (p *Parser) parseGroupedExpression() ast.Expression {
p.nextToken()
exp := p.parseExpression(LOWEST)
if !p.expectPeek(token.RPAREN) {
return nil
}
return exp
}

func (p *Parser) parsePrefixExpression() ast.Expression {
expression := &ast.PrefixExpression{
Token: p.curToken,
Expand Down
Loading

0 comments on commit 7d6f6c7

Please sign in to comment.