@brief Deserializes YAML node properties (anchor and/or tag names) if they exist @param lexer The lexical analyzer to be used. @param last_type The variable to store the last lexical token type. @param line The variable to store the line of either the first property or the last non-property token. @param indent The variable to store the indent of either the first property or the last non-property
| 8087 | /// @param indent The variable to store the indent of either the first property or the last non-property token. |
| 8088 | /// @return true if any property is found, false otherwise. |
| 8089 | bool deserialize_node_properties(lexer_type& lexer, lexical_token& last_token, uint32_t& line, uint32_t& indent) { |
| 8090 | m_needs_anchor_impl = m_needs_tag_impl = false; |
| 8091 | |
| 8092 | lexical_token token = last_token; |
| 8093 | bool ends_loop {false}; |
| 8094 | do { |
| 8095 | if (line < lexer.get_lines_processed()) { |
| 8096 | break; |
| 8097 | } |
| 8098 | |
| 8099 | switch (token.type) { |
| 8100 | case lexical_token_t::ANCHOR_PREFIX: |
| 8101 | if FK_YAML_UNLIKELY (m_needs_anchor_impl) { |
| 8102 | throw parse_error( |
| 8103 | "anchor name cannot be specified more than once to the same node.", |
| 8104 | lexer.get_lines_processed(), |
| 8105 | lexer.get_last_token_begin_pos()); |
| 8106 | } |
| 8107 | |
| 8108 | m_anchor_name = token.str; |
| 8109 | m_needs_anchor_impl = true; |
| 8110 | |
| 8111 | if (!m_needs_tag_impl) { |
| 8112 | line = lexer.get_lines_processed(); |
| 8113 | indent = lexer.get_last_token_begin_pos(); |
| 8114 | } |
| 8115 | |
| 8116 | token = lexer.get_next_token(); |
| 8117 | break; |
| 8118 | case lexical_token_t::TAG_PREFIX: { |
| 8119 | if FK_YAML_UNLIKELY (m_needs_tag_impl) { |
| 8120 | throw parse_error( |
| 8121 | "tag name cannot be specified more than once to the same node.", |
| 8122 | lexer.get_lines_processed(), |
| 8123 | lexer.get_last_token_begin_pos()); |
| 8124 | } |
| 8125 | |
| 8126 | m_tag_name = token.str; |
| 8127 | m_needs_tag_impl = true; |
| 8128 | |
| 8129 | if (!m_needs_anchor_impl) { |
| 8130 | line = lexer.get_lines_processed(); |
| 8131 | indent = lexer.get_last_token_begin_pos(); |
| 8132 | } |
| 8133 | |
| 8134 | token = lexer.get_next_token(); |
| 8135 | break; |
| 8136 | } |
| 8137 | default: |
| 8138 | ends_loop = true; |
| 8139 | break; |
| 8140 | } |
| 8141 | } while (!ends_loop); |
| 8142 | |
| 8143 | last_token = token; |
| 8144 | const bool prop_specified = m_needs_anchor_impl || m_needs_tag_impl; |
| 8145 | if (!prop_specified) { |
| 8146 | line = lexer.get_lines_processed(); |
no test coverage detected