Go to the documentation of this file.
36 #ifndef LLVM_SUPPORT_YAMLPARSER_H
37 #define LLVM_SUPPORT_YAMLPARSER_H
49 #include <system_error>
53 class MemoryBufferRef;
60 class document_iterator;
67 bool dumpTokens(StringRef Input, raw_ostream &);
78 std::string
escape(StringRef Input,
bool EscapePrintable =
true);
89 std::error_code *EC =
nullptr);
92 std::error_code *EC =
nullptr);
113 std::unique_ptr<Scanner> scanner;
114 std::unique_ptr<Document> CurrentDoc;
119 virtual void anchor();
141 size_t Alignment = 16) noexcept {
142 return Alloc.Allocate(Size, Alignment);
146 size_t Size) noexcept {
147 Alloc.Deallocate(Ptr, Size, 0);
150 void operator delete(
void *) noexcept =
delete;
180 std::unique_ptr<Document> &
Doc;
197 void anchor()
override;
212 void anchor()
override;
255 void anchor()
override;
285 void anchor()
override;
339 assert(Base && Base->CurrentEntry &&
"Attempted to access end iterator!");
340 return Base->CurrentEntry;
344 assert(Base && Base->CurrentEntry &&
345 "Attempted to dereference end iterator!");
346 return *Base->CurrentEntry;
350 assert(Base && Base->CurrentEntry &&
"Attempted to access end iterator!");
351 return Base->CurrentEntry;
362 if (Base && (Base ==
Other.Base)) {
363 assert((Base->CurrentEntry ==
Other.Base->CurrentEntry)
364 &&
"Equal Bases expected to point to equal Entries");
367 return Base ==
Other.Base;
371 return !(Base ==
Other.Base);
375 assert(Base &&
"Attempted to advance iterator past end!");
378 if (!Base->CurrentEntry)
384 BaseT *Base =
nullptr;
388 template <
class CollectionType>
389 typename CollectionType::iterator
begin(CollectionType &
C) {
390 assert(
C.IsAtBeginning &&
"You may only iterate over a collection once!");
391 C.IsAtBeginning =
false;
392 typename CollectionType::iterator
ret(&
C);
397 template <
class CollectionType>
void skip(CollectionType &
C) {
399 assert((
C.IsAtBeginning ||
C.IsAtEnd) &&
"Cannot skip mid parse!");
401 for (
typename CollectionType::iterator
i =
begin(
C),
e =
C.end();
i !=
e;
414 void anchor()
override;
431 template <
class T>
friend typename T::iterator
yaml::begin(
T &);
446 bool IsAtBeginning =
true;
447 bool IsAtEnd =
false;
462 void anchor()
override;
486 template <
class T>
friend typename T::iterator
yaml::begin(
T &);
503 bool IsAtBeginning =
true;
504 bool IsAtEnd =
false;
505 bool WasPreviousTokenFlowEntry =
true;
506 Node *CurrentEntry =
nullptr;
514 void anchor()
override;
548 const std::map<StringRef, StringRef> &
getTagMap()
const {
return TagMap; }
566 std::map<StringRef, StringRef> TagMap;
570 void setError(
const Twine &Message,
Token &Location)
const;
574 bool parseDirectives();
577 void parseYAMLDirective();
580 void parseTAGDirective();
583 bool expectToken(
int TK);
593 if (isAtEnd() ||
Other.isAtEnd())
594 return isAtEnd() &&
Other.isAtEnd();
596 return Doc ==
Other.Doc;
599 return !(*
this ==
Other);
603 assert(Doc &&
"incrementing iterator past the end.");
604 if (!(*Doc)->skip()) {
618 bool isAtEnd()
const {
return !Doc || !*Doc; }
620 std::unique_ptr<Document> *Doc =
nullptr;
627 #endif // LLVM_SUPPORT_YAMLPARSER_H
RTTIExtends< ObjectLinkingLayer, ObjectLayer > BaseT
Represents an alias to a Node with an anchor.
A YAML Stream is a sequence of Documents.
document_iterator()=default
This is an optimization pass for GlobalISel generic memory operations.
StringRef getName() const
SMRange getSourceRange() const
StringRef getRawTag() const
Get the tag as it was written in the document.
std::string escape(StringRef Input, bool EscapePrintable=true)
Escape Input for a double quoted scalar; if EscapePrintable is true, all UTF8 sequences will be escap...
Abstract base class for all Nodes.
StringRef getRawValue() const
bool operator!=(const basic_collection_iterator &Other) const
Node * getValue()
Parse and return the value.
basic_collection_iterator< MappingNode, KeyValueNode > iterator
The instances of the Type class are immutable: once they are created, they are never changed.
static bool classof(const Node *N)
A scalar node is an opaque datum that can be presented as a series of zero or more Unicode scalar val...
Represents a YAML map created from either a block map for a flow map.
to esp esp setne al movzbw ax esp setg cl movzbw cx cmove cx cl jne LBB1_2 esp ret(also really horrible code on ppc). This is due to the expand code for 64-bit compares. GCC produces multiple branches
AliasNode(std::unique_ptr< Document > &D, StringRef Val)
Document(Stream &ParentStream)
static bool classof(const Node *N)
This is an iterator abstraction over YAML collections shared by both sequences and maps.
void skip(CollectionType &C)
bool scanTokens(StringRef Input)
Scans all tokens in input without outputting anything.
bool operator!=(const document_iterator &Other) const
StringRef getValue() const
Gets the value of this node as a StringRef.
basic_collection_iterator(BaseT *B)
ValueT & operator*() const
StringRef getAnchor() const
Get the value of the anchor attached to this node.
Node * getKey()
Parse and return the key.
Represents a location in source code.
(vector float) vec_cmpeq(*A, *B) C
Represents a YAML sequence created from either a block sequence for a flow sequence.
Node(unsigned int Type, std::unique_ptr< Document > &, StringRef Anchor, StringRef Tag)
void setSourceRange(SMRange SR)
bool dumpTokens(StringRef Input, raw_ostream &)
Dump all the tokens in this stream to OS.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind=SourceMgr::DK_Error)
static bool classof(const Node *N)
llvm::Optional< bool > parseBool(StringRef S)
Parse S as a bool according to https://yaml.org/type/bool.html.
static bool classof(const Node *N)
static bool classof(const Node *N)
void operator=(const Node &)=delete
@ MT_Inline
An inline mapping node is used for "[key: value]".
std::unique_ptr< Document > & operator->()
A block scalar node is an opaque datum that can be presented as a series of zero or more Unicode scal...
basic_collection_iterator< SequenceNode, Node > iterator
BumpPtrAllocator & getAllocator()
std::unique_ptr< Document > & Doc
Node * parseBlockNode()
Root for parsing a node. Returns a single node.
basic_collection_iterator & operator++()
const std::map< StringRef, StringRef > & getTagMap() const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
std::ptrdiff_t difference_type
static bool classof(const Node *N)
Allocate memory in an ever growing pool, as if by bump-pointer.
Token - A single YAML token.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ValueT * operator->() const
CollectionType::iterator begin(CollectionType &C)
basic_collection_iterator()=default
SequenceNode(std::unique_ptr< Document > &D, StringRef Anchor, StringRef Tag, SequenceType ST)
document_iterator(std::unique_ptr< Document > &D)
Node * getRoot()
Parse and return the root level node.
bool operator==(const document_iterator &Other) const
BlockScalarNode(std::unique_ptr< Document > &D, StringRef Anchor, StringRef Tag, StringRef Value, StringRef RawVal)
StringRef - Represent a constant reference to a string, i.e.
std::string getVerbatimTag() const
Get the verbatium tag for a given Node.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
NullNode(std::unique_ptr< Document > &D)
This class represents a YAML stream potentially containing multiple documents.
Stream(StringRef Input, SourceMgr &, bool ShowColors=true, std::error_code *EC=nullptr)
This keeps a reference to the string referenced by Input.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
ScalarNode(std::unique_ptr< Document > &D, StringRef Anchor, StringRef Tag, StringRef Val)
document_iterator operator++()
bool skip()
Finish parsing the current document and return true if there are more.
const CustomOperand< const MCSubtargetInfo & > Msg[]
document_iterator begin()
StringRef getValue(SmallVectorImpl< char > &Storage) const
Gets the value of this node as a StringRef.
Determine the kind of a node from its type.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool operator==(const basic_collection_iterator &Other) const
Note on EqualityComparable:
KeyValueNode(std::unique_ptr< Document > &D)
Represents a range in source code.
void setError(const Twine &Message, Token &Location) const
static SMLoc getFromPointer(const char *Ptr)
Iterator abstraction for Documents over a Stream.
static bool classof(const Node *N)
MappingNode(std::unique_ptr< Document > &D, StringRef Anchor, StringRef Tag, MappingType MT)
LLVM Value Representation.
unsigned int getType() const
std::input_iterator_tag iterator_category
Optional< std::vector< StOtherPiece > > Other