MCPcopy Create free account
hub / github.com/docopt/docopt.go / parseSeq

Function parseSeq

docopt.go:302–317  ·  view source on GitHub ↗
(tokens *tokenList, options *patternList)

Source from the content-addressed store, hash-verified

300}
301
302func parseSeq(tokens *tokenList, options *patternList) (patternList, error) {
303 // seq ::= ( atom [ '...' ] )* ;
304 result := patternList{}
305 for !tokens.current().match(true, "]", ")", "|") {
306 atom, err := parseAtom(tokens, options)
307 if err != nil {
308 return nil, err
309 }
310 if tokens.current().eq("...") {
311 atom = patternList{newOneOrMore(atom...)}
312 tokens.move()
313 }
314 result = append(result, atom...)
315 }
316 return result, nil
317}
318
319func parseAtom(tokens *tokenList, options *patternList) (patternList, error) {
320 // atom ::= '(' expr ')' | '[' expr ']' | 'options' | long | shorts | argument | command ;

Callers 1

parseExprFunction · 0.85

Calls 6

parseAtomFunction · 0.85
newOneOrMoreFunction · 0.85
currentMethod · 0.80
moveMethod · 0.80
matchMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected