TODO(sbarzowski) - this returned bool is weird
(elementKind string)
| 195 | |
| 196 | // TODO(sbarzowski) - this returned bool is weird |
| 197 | func (p *parser) parseParameters(elementKind string) (*token, []ast.Parameter, bool, errors.StaticError) { |
| 198 | |
| 199 | var parenR *token |
| 200 | var params []ast.Parameter |
| 201 | gotComma := false |
| 202 | first := true |
| 203 | for { |
| 204 | next := p.peek() |
| 205 | |
| 206 | if next.kind == tokenParenR { |
| 207 | // gotComma can be true or false here. |
| 208 | parenR = p.pop() |
| 209 | break |
| 210 | } |
| 211 | |
| 212 | if !first && !gotComma { |
| 213 | return nil, nil, false, errors.MakeStaticError(fmt.Sprintf("Expected a comma before next %s, got %s", elementKind, next), next.loc) |
| 214 | } |
| 215 | |
| 216 | param, err := p.parseParameter() |
| 217 | if err != nil { |
| 218 | return nil, nil, false, err |
| 219 | } |
| 220 | |
| 221 | if p.peek().kind == tokenComma { |
| 222 | comma := p.pop() |
| 223 | param.CommaFodder = comma.fodder |
| 224 | gotComma = true |
| 225 | } else { |
| 226 | gotComma = false |
| 227 | } |
| 228 | params = append(params, param) |
| 229 | |
| 230 | first = false |
| 231 | } |
| 232 | |
| 233 | return parenR, params, gotComma, nil |
| 234 | } |
| 235 | |
| 236 | // TODO(sbarzowski) add location to all individual binds |
| 237 | func (p *parser) parseBind(binds *ast.LocalBinds) (*token, errors.StaticError) { |
no test coverage detected