MCPcopy
hub / github.com/go-yaml/yaml / yaml_parser_fetch_more_tokens

Function yaml_parser_fetch_more_tokens

scannerc.go:657–684  ·  view source on GitHub ↗

Ensure that the tokens queue contains at least one token which can be returned to the Parser.

(parser *yaml_parser_t)

Source from the content-addressed store, hash-verified

655// Ensure that the tokens queue contains at least one token which can be
656// returned to the Parser.
657func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool {
658 // While we need more tokens to fetch, do it.
659 for {
660 // [Go] The comment parsing logic requires a lookahead of two tokens
661 // so that foot comments may be parsed in time of associating them
662 // with the tokens that are parsed before them, and also for line
663 // comments to be transformed into head comments in some edge cases.
664 if parser.tokens_head < len(parser.tokens)-2 {
665 // If a potential simple key is at the head position, we need to fetch
666 // the next token to disambiguate it.
667 head_tok_idx, ok := parser.simple_keys_by_tok[parser.tokens_parsed]
668 if !ok {
669 break
670 } else if valid, ok := yaml_simple_key_is_valid(parser, &parser.simple_keys[head_tok_idx]); !ok {
671 return false
672 } else if !valid {
673 break
674 }
675 }
676 // Fetch the next token.
677 if !yaml_parser_fetch_next_token(parser) {
678 return false
679 }
680 }
681
682 parser.token_available = true
683 return true
684}
685
686// The dispatcher for token fetchers.
687func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) {

Callers 2

peek_tokenFunction · 0.85
yaml_parser_scanFunction · 0.85

Calls 2

yaml_simple_key_is_validFunction · 0.85

Tested by

no test coverage detected