parseSegmentedIdents parses a segmented identifiers. e.g., "db"."rp".measurement or "db"..measurement
()
| 135 | // parseSegmentedIdents parses a segmented identifiers. |
| 136 | // e.g., "db"."rp".measurement or "db"..measurement |
| 137 | func (p *Parser) parseSegmentedIdents() ([]string, error) { |
| 138 | ident, err := p.parseIdent() |
| 139 | if err != nil { |
| 140 | return nil, err |
| 141 | } |
| 142 | idents := []string{ident} |
| 143 | |
| 144 | // Parse remaining (optional) identifiers. |
| 145 | for { |
| 146 | if tok, _, _ := p.scan(); tok != DOT { |
| 147 | // No more segments so we're done. |
| 148 | p.unscan() |
| 149 | break |
| 150 | } |
| 151 | |
| 152 | if ch := p.peekRune(); ch == '/' { |
| 153 | // Next segment is a regex so we're done. |
| 154 | break |
| 155 | } else if ch == '.' { |
| 156 | // Add an empty identifier. |
| 157 | idents = append(idents, "") |
| 158 | continue |
| 159 | } |
| 160 | |
| 161 | // Parse the next identifier. |
| 162 | if ident, err = p.parseIdent(); err != nil { |
| 163 | return nil, err |
| 164 | } |
| 165 | |
| 166 | idents = append(idents, ident) |
| 167 | } |
| 168 | |
| 169 | if len(idents) > 3 { |
| 170 | msg := fmt.Sprintf("too many segments in %s", QuoteIdent(idents...)) |
| 171 | return nil, &ParseError{Message: msg} |
| 172 | } |
| 173 | |
| 174 | return idents, nil |
| 175 | } |
| 176 | |
| 177 | // parserString parses a string. |
| 178 | func (p *Parser) parseString() (string, error) { |
no test coverage detected