MCPcopy Create free account
hub / github.com/LissaGreense/GO4SQL / parseOffsetCommand

Method parseOffsetCommand

parser/parser.go:536–564  ·  view source on GitHub ↗

parseOffsetCommand - Return ast.OffsetCommand created from tokens and validate the syntax Example of input parsable to the ast.LimitCommand: OFFSET 10

()

Source from the content-addressed store, hash-verified

534// Example of input parsable to the ast.LimitCommand:
535// OFFSET 10
536func (parser *Parser) parseOffsetCommand() (ast.Command, error) {
537 // token.OFFSET already at current position in parser
538 offsetCommand := &ast.OffsetCommand{Token: parser.currentToken}
539
540 // token.OFFSET no longer needed
541 parser.nextToken()
542
543 err := validateToken(parser.currentToken.Type, []token.Type{token.LITERAL})
544 if err != nil {
545 return nil, err
546 }
547
548 count, err := strconv.Atoi(parser.currentToken.Literal)
549 if err != nil {
550 return nil, err
551 }
552 if count < 0 {
553 return nil, &ArithmeticLessThanZeroParserError{variable: "offset"}
554 }
555
556 offsetCommand.Count = count
557
558 // Skip token.IDENT
559 parser.nextToken()
560
561 parser.skipIfCurrentTokenIsSemicolon()
562
563 return offsetCommand, nil
564}
565
566// parseJoinCommand - Return ast.JoinCommand created from tokens and validate the syntax
567//

Callers 1

ParseSequenceMethod · 0.95

Calls 3

nextTokenMethod · 0.95
validateTokenFunction · 0.85

Tested by

no test coverage detected