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

Function parseElse

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

Source from the content-addressed store, hash-verified

7)
8
9func parseElse(tokens token.List, file *fs.File, nodes AST) (Node, error) {
10 if len(nodes) == 0 {
11 return nil, errors.New(ExpectedIfBeforeElse, file, tokens[0])
12 }
13
14 blockStart, _, body, err := block(tokens, file)
15
16 if err != nil {
17 return nil, err
18 }
19
20 if blockStart != 1 {
21 if tokens[1].Kind == token.If {
22 return nil, errors.New(NoElseIf, file, tokens[:2])
23 }
24
25 return nil, errors.New(ExpectedBlock, file, tokens[1:blockStart])
26 }
27
28 last := nodes[len(nodes)-1]

Callers 1

parseKeywordFunction · 0.85

Calls 2

NewFunction · 0.92
blockFunction · 0.85

Tested by

no test coverage detected