| 48 | } |
| 49 | |
| 50 | void SingleDocParser::HandleNode(EventHandler& eventHandler) { |
| 51 | DepthGuard<500> depthguard(depth, m_scanner.mark(), ErrorMsg::BAD_FILE); |
| 52 | |
| 53 | // an empty node *is* a possibility |
| 54 | if (m_scanner.empty()) { |
| 55 | eventHandler.OnNull(m_scanner.mark(), NullAnchor); |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | // save location |
| 60 | Mark mark = m_scanner.peek().mark; |
| 61 | |
| 62 | // special case: a value node by itself must be a map, with no header |
| 63 | if (m_scanner.peek().type == Token::VALUE) { |
| 64 | eventHandler.OnMapStart(mark, "?", NullAnchor, EmitterStyle::Default); |
| 65 | HandleMap(eventHandler); |
| 66 | eventHandler.OnMapEnd(); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | // special case: an alias node |
| 71 | if (m_scanner.peek().type == Token::ALIAS) { |
| 72 | eventHandler.OnAlias(mark, LookupAnchor(mark, m_scanner.peek().value)); |
| 73 | m_scanner.pop(); |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | std::string tag; |
| 78 | std::string anchor_name; |
| 79 | anchor_t anchor; |
| 80 | ParseProperties(tag, anchor, anchor_name); |
| 81 | |
| 82 | if (!anchor_name.empty()) |
| 83 | eventHandler.OnAnchor(mark, anchor_name); |
| 84 | |
| 85 | // after parsing properties, an empty node is again a possibility |
| 86 | if (m_scanner.empty()) { |
| 87 | eventHandler.OnNull(mark, anchor); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | const Token& token = m_scanner.peek(); |
| 92 | |
| 93 | // add non-specific tags |
| 94 | if (tag.empty()) |
| 95 | tag = (token.type == Token::NON_PLAIN_SCALAR ? "!" : "?"); |
| 96 | |
| 97 | if (token.type == Token::PLAIN_SCALAR |
| 98 | && tag.compare("?") == 0 && IsNullString(token.value)) { |
| 99 | eventHandler.OnNull(mark, anchor); |
| 100 | m_scanner.pop(); |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | // now split based on what kind of node we should be |
| 105 | switch (token.type) { |
| 106 | case Token::PLAIN_SCALAR: |
| 107 | case Token::NON_PLAIN_SCALAR: |
nothing calls this directly
no test coverage detected