38 #ifndef LLVM_SUPPORT_YAMLPARSER_H
39 #define LLVM_SUPPORT_YAMLPARSER_H
59 class document_iterator;
67 bool dumpTokens(StringRef Input, raw_ostream &);
75 std::string
escape(StringRef Input);
108 virtual void anchor();
149 void *
operator new (
size_t Size
151 ,
size_t Alignment = 16)
throw() {
152 return Alloc.Allocate(Size, Alignment);
156 Alloc.Deallocate(Ptr);
163 void operator delete(
void *)
throw() {}
179 virtual void anchor();
195 virtual void anchor();
237 virtual void anchor();
278 template <
class BaseT,
class ValueT>
280 :
public std::iterator<std::forward_iterator_tag, ValueT> {
286 assert(Base && Base->CurrentEntry &&
"Attempted to access end iterator!");
287 return Base->CurrentEntry;
291 assert(Base && Base->CurrentEntry &&
292 "Attempted to dereference end iterator!");
293 return *Base->CurrentEntry;
296 operator ValueT*()
const {
297 assert(Base && Base->CurrentEntry &&
"Attempted to access end iterator!");
298 return Base->CurrentEntry;
302 if(Base != Other.Base)
304 return (Base && Other.Base) && Base->CurrentEntry
305 != Other.Base->CurrentEntry;
309 assert(Base &&
"Attempted to advance iterator past end!");
312 if (Base->CurrentEntry == 0)
322 template <
class CollectionType>
323 typename CollectionType::iterator
begin(CollectionType &
C) {
324 assert(C.IsAtBeginning &&
"You may only iterate over a collection once!");
325 C.IsAtBeginning =
false;
326 typename CollectionType::iterator ret(&C);
331 template <
class CollectionType>
334 assert((C.IsAtBeginning || C.IsAtEnd) &&
"Cannot skip mid parse!");
336 for (
typename CollectionType::iterator i =
begin(C), e = C.end();
349 virtual void anchor();
360 IsAtEnd(
false), CurrentEntry(0) {}
364 template <
class T>
friend typename T::iterator
yaml::begin(
T &);
399 virtual void anchor();
418 WasPreviousTokenFlowEntry(
true),
423 template <
class T>
friend typename T::iterator
yaml::begin(
T &);
446 bool WasPreviousTokenFlowEntry;
455 virtual void anchor();
491 const std::map<StringRef, StringRef> &
getTagMap()
const {
511 std::map<StringRef, StringRef> TagMap;
515 void setError(
const Twine &Message,
Token &Location)
const;
519 bool parseDirectives();
522 void parseYAMLDirective();
525 void parseTAGDirective();
528 bool expectToken(
int TK);
538 if (isAtEnd() || Other.isAtEnd())
539 return isAtEnd() && Other.isAtEnd();
541 return Doc == Other.Doc;
544 return !(*
this == Other);
548 assert(Doc != 0 &&
"incrementing iterator past the end.");
549 if (!(*Doc)->skip()) {
552 Stream &S = (*Doc)->stream;
567 bool isAtEnd()
const {
568 return !Doc || !*Doc;
static bool classof(const Node *N)
document_iterator operator++()
Node(unsigned int Type, OwningPtr< Document > &, StringRef Anchor, StringRef Tag)
COFF::RelocationTypeX86 Type
virtual void skip() LLVM_OVERRIDE
const std::map< StringRef, StringRef > & getTagMap() const
ScalarNode(OwningPtr< Document > &D, StringRef Anchor, StringRef Tag, StringRef Val)
OwningPtr< Document > & Doc
std::string getVerbatimTag() const
Get the verbatium tag for a given Node. This performs tag resoluton and substitution.
bool scanTokens(StringRef Input)
Scans all tokens in input without outputting anything. This is used for benchmarking the tokenizer...
This is an iterator abstraction over YAML collections shared by both sequences and maps...
StringRef getValue(SmallVectorImpl< char > &Storage) const
Gets the value of this node as a StringRef.
StringRef getRawTag() const
Get the tag as it was written in the document. This does not perform tag resolution.
Represents a YAML sequence created from either a block sequence for a flow sequence.
Node * getKey()
Parse and return the key.
document_iterator begin()
Represents an alias to a Node with an anchor.
void skip(CollectionType &C)
static bool classof(const Node *N)
static bool classof(const Node *N)
void setError(const Twine &Message, Token &Location) const
StringRef getRawValue() const
virtual void skip() LLVM_OVERRIDE
CollectionType::iterator begin(CollectionType &C)
A key and value pair. While not technically a Node under the YAML representation graph, it is easier to treat them this way.
Node * getRoot()
Parse and return the root level node.
basic_collection_iterator< SequenceNode, Node > iterator
static bool classof(const Node *N)
SequenceNode(OwningPtr< Document > &D, StringRef Anchor, StringRef Tag, SequenceType ST)
bool dumpTokens(StringRef Input, raw_ostream &)
Dump all the tokens in this stream to OS.
virtual void skip() LLVM_OVERRIDE
void printError(Node *N, const Twine &Msg)
Stream(StringRef Input, SourceMgr &)
This keeps a reference to the string referenced by Input.
KeyValueNode(OwningPtr< Document > &D)
std::string escape(StringRef Input)
Escape Input for a double quoted scalar.
Document(Stream &ParentStream)
document_iterator(OwningPtr< Document > &D)
OwningPtr< Document > & operator->()
BumpPtrAllocator & getAllocator()
A scalar node is an opaque datum that can be presented as a series of zero or more Unicode scalar val...
static bool classof(const Node *N)
NullNode(OwningPtr< Document > &D)
void setSourceRange(SMRange SR)
ValueT * operator->() const
AliasNode(OwningPtr< Document > &D, StringRef Val)
Node * getValue()
Parse and return the value.
basic_collection_iterator(BaseT *B)
bool skip()
Finish parsing the current document and return true if there are more. Return false otherwise...
basic_collection_iterator()
This class represents a YAML stream potentially containing multiple documents.
StringRef getAnchor() const
Get the value of the anchor attached to this node. If it does not have one, getAnchor().size() will be 0.
StringRef getName() const
bool operator!=(const basic_collection_iterator &Other) const
static SMLoc getFromPointer(const char *Ptr)
SMRange getSourceRange() const
static bool classof(const Node *N)
Token - A single YAML token.
Represents a YAML map created from either a block map for a flow map.
ValueT & operator*() const
Iterator abstraction for Documents over a Stream.
unsigned int getType() const
basic_collection_iterator< MappingNode, KeyValueNode > iterator
LLVM Value Representation.
MappingNode(OwningPtr< Document > &D, StringRef Anchor, StringRef Tag, MappingType MT)
bool operator==(const document_iterator &Other)
basic_collection_iterator & operator++()
Represents a location in source code.
bool operator!=(const document_iterator &Other)
An inline mapping node is used for "[key: value]".
Node * parseBlockNode()
Root for parsing a node. Returns a single node.
A YAML Stream is a sequence of Documents. A document contains a root node.
Abstract base class for all Nodes.