(tokens token.List, file *fs.File)
| 7 | "git.urbach.dev/cli/q/src/token" |
| 8 | ) |
| 9 | |
| 10 | func parseSwitch(tokens token.List, file *fs.File) (Node, error) { |
| 11 | var ( |
| 12 | head *expression.Expression |
| 13 | blockStart = tokens.IndexKind(token.BlockStart) |
| 14 | blockEnd = tokens.LastIndexKind(token.BlockEnd) |
| 15 | ) |
| 16 | |
| 17 | if blockStart == -1 { |
| 18 | return nil, errors.NewAt(MissingBlockStart, file, tokens[0].End()) |
| 19 | } |
| 20 | |
| 21 | if blockEnd == -1 { |
| 22 | return nil, errors.NewAt(MissingBlockEnd, file, tokens[len(tokens)-1].End()) |
| 23 | } |
| 24 | |
| 25 | headTokens := tokens[1:blockStart] |
| 26 | |
| 27 | if len(headTokens) > 0 { |
| 28 | head = expression.Parse(headTokens) |
| 29 | } |
| 30 | |
| 31 | body := tokens[blockStart+1 : blockEnd] |
| 32 |
no test coverage detected