MCPcopy Index your code
hub / github.com/LissaGreense/GO4SQL / parseWhereCommand

Method parseWhereCommand

parser/parser.go:353–378  ·  view source on GitHub ↗

parseWhereCommand - Return ast.WhereCommand created from tokens and validate the syntax Example of input parsable to the ast.WhereCommand: WHERE colName EQUAL 'potato'

()

Source from the content-addressed store, hash-verified

351// Example of input parsable to the ast.WhereCommand:
352// WHERE colName EQUAL 'potato'
353func (parser *Parser) parseWhereCommand() (ast.Command, error) {
354 // token.WHERE already at current position in parser
355 whereCommand := &ast.WhereCommand{Token: parser.currentToken}
356 expressionIsValid := false
357
358 // Ignore token.WHERE
359 parser.nextToken()
360 var err error
361 expressionIsValid, whereCommand.Expression, err = parser.getExpression()
362 if err != nil {
363 return nil, err
364 }
365
366 if !expressionIsValid {
367 return nil, &LogicalExpressionParsingError{}
368 }
369
370 err = validateToken(parser.currentToken.Type, []token.Type{token.SEMICOLON, token.ORDER})
371 if err != nil {
372 return nil, err
373 }
374
375 parser.skipIfCurrentTokenIsSemicolon()
376
377 return whereCommand, nil
378}
379
380// parseDeleteCommand - Return ast.DeleteCommand created from tokens and validate the syntax
381//

Callers 1

ParseSequenceMethod · 0.95

Calls 4

nextTokenMethod · 0.95
getExpressionMethod · 0.95
validateTokenFunction · 0.85

Tested by

no test coverage detected