| 1812 | } |
| 1813 | |
| 1814 | std::string Node::getVerbatimTag() const { |
| 1815 | StringRef Raw = getRawTag(); |
| 1816 | if (!Raw.empty() && Raw != "!") { |
| 1817 | std::string Ret; |
| 1818 | if (Raw.find_last_of('!') == 0) { |
| 1819 | Ret = std::string(Doc->getTagMap().find("!")->second); |
| 1820 | Ret += Raw.substr(1); |
| 1821 | return Ret; |
| 1822 | } else if (Raw.startswith("!!")) { |
| 1823 | Ret = std::string(Doc->getTagMap().find("!!")->second); |
| 1824 | Ret += Raw.substr(2); |
| 1825 | return Ret; |
| 1826 | } else { |
| 1827 | StringRef TagHandle = Raw.substr(0, Raw.find_last_of('!') + 1); |
| 1828 | std::map<StringRef, StringRef>::const_iterator It = |
| 1829 | Doc->getTagMap().find(TagHandle); |
| 1830 | if (It != Doc->getTagMap().end()) |
| 1831 | Ret = std::string(It->second); |
| 1832 | else { |
| 1833 | Token T; |
| 1834 | T.Kind = Token::TK_Tag; |
| 1835 | T.Range = TagHandle; |
| 1836 | setError(Twine("Unknown tag handle ") + TagHandle, T); |
| 1837 | } |
| 1838 | Ret += Raw.substr(Raw.find_last_of('!') + 1); |
| 1839 | return Ret; |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | switch (getType()) { |
| 1844 | case NK_Null: |
| 1845 | return "tag:yaml.org,2002:null"; |
| 1846 | case NK_Scalar: |
| 1847 | case NK_BlockScalar: |
| 1848 | // TODO: Tag resolution. |
| 1849 | return "tag:yaml.org,2002:str"; |
| 1850 | case NK_Mapping: |
| 1851 | return "tag:yaml.org,2002:map"; |
| 1852 | case NK_Sequence: |
| 1853 | return "tag:yaml.org,2002:seq"; |
| 1854 | } |
| 1855 | |
| 1856 | return ""; |
| 1857 | } |
| 1858 | |
| 1859 | Token &Node::peekNext() { |
| 1860 | return Doc->peekNext(); |
no test coverage detected