diff --git a/parser/parser.go b/parser/parser.go index 88ae994..90d1287 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -152,10 +152,6 @@ func (p *parser) parseDocumentBody(ctx *context) (ast.Node, error) { } func (p *parser) parseToken(ctx *context, tk *Token) (ast.Node, error) { - if tk == nil { - return nil, nil - } - switch tk.GroupType() { case TokenGroupMapKey, TokenGroupMapKeyValue: return p.parseMap(ctx) @@ -1067,12 +1063,12 @@ func (p *parser) parseDirective(ctx *context, g *TokenGroup) (*ast.DirectiveNode func (p *parser) parseComment(ctx *context) (ast.Node, error) { cm := p.parseHeadComment(ctx) - nextTok := ctx.currentToken() - if nextTok == nil { + tk := ctx.currentToken() + if tk == nil { return cm, nil } - node, err := p.parseToken(ctx, nextTok) + node, err := p.parseToken(ctx, tk) if err != nil { return nil, err }