X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FYAMLParser.h;h=0fbb7d2e6c7e3fc3afe452333f35f1e3188ca8b4;hb=00552e3875ee5f382db6c98286a241a7d0efe1b8;hp=db888b816cfec69480a2d756c916cdf1203b9678;hpb=9daa4b18f7525087c9b4df705d793aa30e4f6417;p=oota-llvm.git diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index db888b816cf..0fbb7d2e6c7 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -76,9 +76,9 @@ std::string escape(StringRef Input); class Stream { public: /// \brief This keeps a reference to the string referenced by \p Input. - Stream(StringRef Input, SourceMgr &); + Stream(StringRef Input, SourceMgr &, bool ShowColors = true); - Stream(MemoryBufferRef InputBuffer, SourceMgr &); + Stream(MemoryBufferRef InputBuffer, SourceMgr &, bool ShowColors = true); ~Stream(); document_iterator begin(); @@ -107,6 +107,7 @@ public: enum NodeKind { NK_Null, NK_Scalar, + NK_BlockScalar, NK_KeyValue, NK_Mapping, NK_Sequence, @@ -158,7 +159,7 @@ protected: void operator delete(void *) throw() {} - virtual ~Node() {} + ~Node() = default; private: unsigned int TypeID; @@ -171,7 +172,7 @@ private: /// /// Example: /// !!null null -class NullNode : public Node { +class NullNode final : public Node { void anchor() override; public: @@ -186,7 +187,7 @@ public: /// /// Example: /// Adena -class ScalarNode : public Node { +class ScalarNode final : public Node { void anchor() override; public: @@ -222,6 +223,36 @@ private: SmallVectorImpl &Storage) const; }; +/// \brief A block scalar node is an opaque datum that can be presented as a +/// series of zero or more Unicode scalar values. +/// +/// Example: +/// | +/// Hello +/// World +class BlockScalarNode final : public Node { + void anchor() override; + +public: + BlockScalarNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag, + StringRef Value, StringRef RawVal) + : Node(NK_BlockScalar, D, Anchor, Tag), Value(Value) { + SMLoc Start = SMLoc::getFromPointer(RawVal.begin()); + SMLoc End = SMLoc::getFromPointer(RawVal.end()); + SourceRange = SMRange(Start, End); + } + + /// \brief Gets the value of this node as a StringRef. + StringRef getValue() const { return Value; } + + static inline bool classof(const Node *N) { + return N->getType() == NK_BlockScalar; + } + +private: + StringRef Value; +}; + /// \brief A key and value pair. While not technically a Node under the YAML /// representation graph, it is easier to treat them this way. /// @@ -229,7 +260,7 @@ private: /// /// Example: /// Section: .text -class KeyValueNode : public Node { +class KeyValueNode final : public Node { void anchor() override; public: @@ -340,7 +371,7 @@ template void skip(CollectionType &C) { /// Example: /// Name: _main /// Scope: Global -class MappingNode : public Node { +class MappingNode final : public Node { void anchor() override; public: @@ -387,7 +418,7 @@ private: /// Example: /// - Hello /// - World -class SequenceNode : public Node { +class SequenceNode final : public Node { void anchor() override; public: @@ -440,7 +471,7 @@ private: /// /// Example: /// *AnchorName -class AliasNode : public Node { +class AliasNode final : public Node { void anchor() override; public: