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

Function yaml_parser_parse_flow_mapping_key

parserc.go:1066–1127  ·  view source on GitHub ↗

Parse the productions: flow_mapping ::= FLOW-MAPPING-START ****************** (flow_mapping_entry FLOW-ENTRY)* * ********** flow_mapping_entry? ****************** FLOW-MAPPING-END **************** flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? *

(parser *yaml_parser_t, event *yaml_event_t, first bool)

Source from the content-addressed store, hash-verified

1064// * *** *
1065//
1066func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
1067 if first {
1068 token := peek_token(parser)
1069 parser.marks = append(parser.marks, token.start_mark)
1070 skip_token(parser)
1071 }
1072
1073 token := peek_token(parser)
1074 if token == nil {
1075 return false
1076 }
1077
1078 if token.typ != yaml_FLOW_MAPPING_END_TOKEN {
1079 if !first {
1080 if token.typ == yaml_FLOW_ENTRY_TOKEN {
1081 skip_token(parser)
1082 token = peek_token(parser)
1083 if token == nil {
1084 return false
1085 }
1086 } else {
1087 context_mark := parser.marks[len(parser.marks)-1]
1088 parser.marks = parser.marks[:len(parser.marks)-1]
1089 return yaml_parser_set_parser_error_context(parser,
1090 "while parsing a flow mapping", context_mark,
1091 "did not find expected ',' or '}'", token.start_mark)
1092 }
1093 }
1094
1095 if token.typ == yaml_KEY_TOKEN {
1096 skip_token(parser)
1097 token = peek_token(parser)
1098 if token == nil {
1099 return false
1100 }
1101 if token.typ != yaml_VALUE_TOKEN &&
1102 token.typ != yaml_FLOW_ENTRY_TOKEN &&
1103 token.typ != yaml_FLOW_MAPPING_END_TOKEN {
1104 parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE)
1105 return yaml_parser_parse_node(parser, event, false, false)
1106 } else {
1107 parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE
1108 return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
1109 }
1110 } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN {
1111 parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE)
1112 return yaml_parser_parse_node(parser, event, false, false)
1113 }
1114 }
1115
1116 parser.state = parser.states[len(parser.states)-1]
1117 parser.states = parser.states[:len(parser.states)-1]
1118 parser.marks = parser.marks[:len(parser.marks)-1]
1119 *event = yaml_event_t{
1120 typ: yaml_MAPPING_END_EVENT,
1121 start_mark: token.start_mark,
1122 end_mark: token.end_mark,
1123 }

Callers 1

Calls 6

peek_tokenFunction · 0.85
skip_tokenFunction · 0.85
yaml_parser_parse_nodeFunction · 0.85

Tested by

no test coverage detected