Skip to content

Commit

Permalink
handle with linter error (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Sep 28, 2024
1 parent aa3c84e commit 6bd7d6f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,30 @@ func (p *Parser) parseExpression() (ast.Expression, error) {
return p.parseAtom()
}

func (p *Parser) parseObject() (ast.Expression, error) {
defer p.expectCurToken(token.RBRACE)

func (p *Parser) parseObject() (obj ast.Expression, err error) {
if err := p.expectCurToken(token.LBRACE); err != nil {
return nil, err
}

switch p.peekToken.Type {
case token.COMMAND:
return p.parseCommand()
obj, err = p.parseCommand()
case token.IF:
return p.parseIfExpression()
obj, err = p.parseIfExpression()
case token.SET:
return p.parseSetExpression()
obj, err = p.parseSetExpression()
default:
return nil, fmt.Errorf("unexpected token type %s", p.curToken.Type)
err = fmt.Errorf("unexpected token type %s", p.curToken.Type)
}
if err != nil {
return nil, err
}

if err := p.expectCurToken(token.RBRACE); err != nil {
return nil, err
}

return obj, nil
}

func (p *Parser) parseCommand() (*ast.CommandObject, error) {
Expand Down

0 comments on commit 6bd7d6f

Please sign in to comment.