MCPcopy Create free account
hub / github.com/akyoto/q / parseSwitch

Function parseSwitch

src/ast/parseSwitch.go:9–29  ·  view source on GitHub ↗
(tokens token.List, file *fs.File)

Source from the content-addressed store, hash-verified

7 "git.urbach.dev/cli/q/src/token"
8)
9
10func 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

Callers 1

parseKeywordFunction · 0.85

Calls 6

NewAtFunction · 0.92
NewFunction · 0.92
parseCasesFunction · 0.85
IndexKindMethod · 0.80
LastIndexKindMethod · 0.80
EndMethod · 0.65

Tested by

no test coverage detected