code: func (p *Parser) parseResample() (time.Duration, time.Duration, error) {
  	var interval time.Duration
  	if tok, _, _ := p.ScanIgnoreWhitespace(); tok == EVERY {
  		tok, pos, lit := p.ScanIgnoreWhitespace()
  		if tok != DURATIONVAL {
  			return 0, 0, newParseError(tokstr(tok, lit), []string{"duration"}, pos)
  		}
  
  		d, err := ParseDuration(lit)
  		if err != nil {
  			return 0, 0, &ParseError{Message: err.Error(), Pos: pos}
  		}
  		interval = d
  	} else {
  		p.Unscan()
  	}
  
  	var maxDuration time.Duration
  	if tok, _, _ := p.ScanIgnoreWhitespace(); tok == FOR {
  		tok, pos, lit := p.ScanIgnoreWhitespace()
  		if tok != DURATIONVAL {
  			return 0, 0, newParseError(tokstr(tok, lit), []string{"duration"}, pos)
  		}
  
  		d, err := ParseDuration(lit)
  		if err != nil {
  			return 0, 0, &ParseError{Message: err.Error(), Pos: pos}
  		}
  		maxDuration = d
  	} else {
  		p.Unscan()
  	}
  
  	// Neither EVERY or FOR were read, so read the next token again
  	// so we can return a suitable error message.
  	if interval == 0 && maxDuration == 0 {
  		tok, pos, lit := p.ScanIgnoreWhitespace()
  		return 0, 0, newParseError(tokstr(tok, lit), []string{"EVERY", "FOR"}, pos)
  	}
  	return interval, maxDuration, nil
  }
docs: // parseResample parses a RESAMPLE [EVERY <duration>] [FOR <duration>].
  // This function assumes RESAMPLE has already been consumed.
  // EVERY and FOR are optional, but at least one of the two has to be used.