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

Function parseLoop

src/ast/parseLoop.go:10–36  ·  view source on GitHub ↗
(tokens token.List, file *fs.File)

Source from the content-addressed store, hash-verified

8)
9
10func parseLoop(tokens token.List, file *fs.File) (Node, error) {
11 if len(tokens) < 3 {
12 return nil, errors.New(InvalidInstruction, file, tokens)
13 }
14
15 if tokens[1].Kind == token.Dot {
16 control := &LoopControl{
17 Expression: expression.Parse(tokens[2:]),
18 }
19
20 return control, nil
21 }
22
23 blockStart, _, body, err := block(tokens, file)
24 headTokens := tokens[1:blockStart]
25
26 loop := &Loop{
27 Head: nil,
28 Body: body,
29 }
30
31 if len(headTokens) > 0 {
32 loop.Head = expression.Parse(headTokens)
33 }
34
35 return loop, err
36}

Callers 1

parseKeywordFunction · 0.85

Calls 3

NewFunction · 0.92
ParseFunction · 0.92
blockFunction · 0.85

Tested by

no test coverage detected