Skip to content

Commit

Permalink
Merge pull request #307 from 1046102779/master
Browse files Browse the repository at this point in the history
fixed bug: unexpected method has a error
  • Loading branch information
chris-ramon authored Apr 4, 2018
2 parents 8ab5400 + 730e093 commit 609745a
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions language/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ func parseDocument(parser *Parser) (*ast.Document, error) {
}
nodes = append(nodes, node)
default:
if err := unexpected(parser, lexer.Token{}); err != nil {
return nil, err
}
return nil, unexpected(parser, lexer.Token{})
}
} else if peekDescription(parser) {
node, err := parseTypeSystemDefinition(parser)
Expand All @@ -169,9 +167,7 @@ func parseDocument(parser *Parser) (*ast.Document, error) {
}
nodes = append(nodes, node)
} else {
if err := unexpected(parser, lexer.Token{}); err != nil {
return nil, err
}
return nil, unexpected(parser, lexer.Token{})
}
}
return ast.NewDocument(&ast.Document{
Expand Down Expand Up @@ -640,10 +636,8 @@ func parseValueLiteral(parser *Parser, isConst bool) (ast.Value, error) {
return parseVariable(parser)
}
}
if err := unexpected(parser, lexer.Token{}); err != nil {
return nil, err
}
return nil, nil

return nil, unexpected(parser, lexer.Token{})
}

func parseConstValue(parser *Parser) (interface{}, error) {
Expand Down Expand Up @@ -1570,11 +1564,9 @@ func expectKeyWord(parser *Parser, value string) (lexer.Token, error) {
// Helper function for creating an error when an unexpected lexed token
// is encountered.
func unexpected(parser *Parser, atToken lexer.Token) error {
var token lexer.Token
var token = atToken
if (atToken == lexer.Token{}) {
token = parser.Token
} else {
token = parser.Token
}
description := fmt.Sprintf("Unexpected %v", lexer.GetTokenDesc(token))
return gqlerrors.NewSyntaxError(parser.Source, token.Start, description)
Expand Down

0 comments on commit 609745a

Please sign in to comment.