class Scanner
Declaration
class Scanner { /* full declaration omitted */ };
Description
Scans YAML tokens from a MemoryBuffer.
Declared at: llvm/lib/Support/YAMLParser.cpp:248
Member Variables
- private llvm::SourceMgr& SM
- The SourceMgr used for diagnostics and buffer management.
- private llvm::MemoryBufferRef InputBuffer
- The original input.
- private StringRef::iterator Current
- The current position of the scanner.
- private StringRef::iterator End
- The end of the input (one past the last character).
- private int Indent
- Current YAML indentation level in spaces.
- private unsigned int Column
- Current column number in Unicode code points.
- private unsigned int Line
- Current line number.
- private unsigned int FlowLevel
- How deep we are in flow style containers. 0 Means at block level.
- private bool IsStartOfStream
- Are we at the start of the stream?
- private bool IsSimpleKeyAllowed
- Can the next token be the start of a simple key?
- private bool Failed
- True if an error has occurred.
- private bool ShowColors
- Should colors be used when printing out the diagnostic messages?
- private TokenQueueT TokenQueue
- Queue of tokens. This is required to queue up tokens while looking for the end of a simple key. And for cases where a single character can produce multiple tokens (e.g. BlockEnd).
- private SmallVector<int, 4> Indents
- Indentation levels.
- private anonymous struct / union SimpleKeys
- Potential simple keys.
- private std::error_code* EC
Method Overview
- public Scanner(llvm::MemoryBufferRef Buffer, llvm::SourceMgr & SM_, bool ShowColors = true, std::error_code * EC = nullptr)
- public Scanner(llvm::StringRef Input, llvm::SourceMgr & SM, bool ShowColors = true, std::error_code * EC = nullptr)
- private void advanceWhile(llvm::yaml::Scanner::SkipWhileFunc Func)
- private bool consume(uint32_t Expected)
- private bool consumeLineBreakIfPresent()
- private llvm::StringRef currentInput()
- private UTF8Decoded decodeUTF8(StringRef::iterator Position)
- public bool failed()
- private bool fetchMoreTokens()
- private bool findBlockScalarIndent(unsigned int & BlockIndent, unsigned int BlockExitIndent, unsigned int & LineBreaks, bool & IsDone)
- public llvm::yaml::Token getNext()
- private void init(llvm::MemoryBufferRef Buffer)
- private bool isBlankOrBreak(StringRef::iterator Position)
- private bool isLineEmpty(llvm::StringRef Line)
- public llvm::yaml::Token & peekNext()
- public void printError(llvm::SMLoc Loc, SourceMgr::DiagKind Kind, const llvm::Twine & Message, ArrayRef<llvm::SMRange> Ranges = None)
- private void removeSimpleKeyCandidatesOnFlowLevel(unsigned int Level)
- private void removeStaleSimpleKeyCandidates()
- private bool rollIndent(int ToColumn, Token::TokenKind Kind, TokenQueueT::iterator InsertPoint)
- private void saveSimpleKeyCandidate(TokenQueueT::iterator Tok, unsigned int AtColumn, bool IsRequired)
- private bool scanAliasOrAnchor(bool IsAlias)
- private char scanBlockChompingIndicator()
- private bool scanBlockEntry()
- private unsigned int scanBlockIndentationIndicator()
- private bool scanBlockScalar(bool IsLiteral)
- private bool scanBlockScalarHeader(char & ChompingIndicator, unsigned int & IndentIndicator, bool & IsDone)
- private bool scanBlockScalarIndent(unsigned int BlockIndent, unsigned int BlockExitIndent, bool & IsDone)
- private bool scanBlockScalarIndicators(char & StyleIndicator, char & ChompingIndicator, unsigned int & IndentIndicator, bool & IsDone)
- private char scanBlockStyleIndicator()
- private bool scanDirective()
- private bool scanDocumentIndicator(bool IsStart)
- private bool scanFlowCollectionEnd(bool IsSequence)
- private bool scanFlowCollectionStart(bool IsSequence)
- private bool scanFlowEntry()
- private bool scanFlowScalar(bool IsDoubleQuoted)
- private bool scanKey()
- private bool scanPlainScalar()
- private bool scanStreamEnd()
- private bool scanStreamStart()
- private bool scanTag()
- private void scanToNextToken()
- private bool scanValue()
- private void scan_ns_uri_char()
- public void setError(const llvm::Twine & Message, StringRef::iterator Position)
- private void skip(uint32_t Distance)
- private void skipComment()
- private StringRef::iterator skip_b_break(StringRef::iterator Position)
- private StringRef::iterator skip_nb_char(StringRef::iterator Position)
- private StringRef::iterator skip_ns_char(StringRef::iterator Position)
- private StringRef::iterator skip_s_space(StringRef::iterator Position)
- private StringRef::iterator skip_s_white(StringRef::iterator Position)
- private StringRef::iterator skip_while(llvm::yaml::Scanner::SkipWhileFunc Func, StringRef::iterator Position)
- private bool unrollIndent(int ToColumn)
Methods
¶Scanner(llvm::MemoryBufferRef Buffer,
llvm::SourceMgr& SM_,
bool ShowColors = true,
std::error_code* EC = nullptr)
Scanner(llvm::MemoryBufferRef Buffer,
llvm::SourceMgr& SM_,
bool ShowColors = true,
std::error_code* EC = nullptr)
Declared at: llvm/lib/Support/YAMLParser.cpp:252
Parameters
- llvm::MemoryBufferRef Buffer
- llvm::SourceMgr& SM_
- bool ShowColors = true
- std::error_code* EC = nullptr
¶Scanner(llvm::StringRef Input,
llvm::SourceMgr& SM,
bool ShowColors = true,
std::error_code* EC = nullptr)
Scanner(llvm::StringRef Input,
llvm::SourceMgr& SM,
bool ShowColors = true,
std::error_code* EC = nullptr)
Declared at: llvm/lib/Support/YAMLParser.cpp:250
Parameters
- llvm::StringRef Input
- llvm::SourceMgr& SM
- bool ShowColors = true
- std::error_code* EC = nullptr
¶void advanceWhile(
llvm::yaml::Scanner::SkipWhileFunc Func)
void advanceWhile(
llvm::yaml::Scanner::SkipWhileFunc Func)
Description
Skip minimal well-formed code unit subsequences until Func returns its input.
Declared at: llvm/lib/Support/YAMLParser.cpp:376
Parameters
- llvm::yaml::Scanner::SkipWhileFunc Func
¶bool consume(uint32_t Expected)
bool consume(uint32_t Expected)
Description
Consume a minimal well-formed code unit subsequence starting at\a Cur. Return false if it is not the same Unicode scalar value as\a Expected. This updates \a Column.
Declared at: llvm/lib/Support/YAMLParser.cpp:386
Parameters
- uint32_t Expected
¶bool consumeLineBreakIfPresent()
bool consumeLineBreakIfPresent()
Description
Consume a single b-break[28] if it's present at the current position. Return false if the code unit at the current position isn't a line break.
Declared at: llvm/lib/Support/YAMLParser.cpp:401
¶llvm::StringRef currentInput()
llvm::StringRef currentInput()
Declared at: llvm/lib/Support/YAMLParser.cpp:289
¶UTF8Decoded decodeUTF8(
StringRef::iterator Position)
UTF8Decoded decodeUTF8(
StringRef::iterator Position)
Description
Decode a UTF-8 minimal well-formed code unit subsequence starting at \a Position. If the UTF-8 code units starting at Position do not form a well-formed code unit subsequence, then the Unicode scalar value is 0, and the length is 0.
Declared at: llvm/lib/Support/YAMLParser.cpp:299
Parameters
- StringRef::iterator Position
¶bool failed()
bool failed()
Description
Returns true if an error occurred while parsing.
Declared at: llvm/lib/Support/YAMLParser.cpp:282
¶bool fetchMoreTokens()
bool fetchMoreTokens()
Description
Dispatch to the next scanning function based on \a *Cur.
Declared at: llvm/lib/Support/YAMLParser.cpp:516
¶bool findBlockScalarIndent(
unsigned int& BlockIndent,
unsigned int BlockExitIndent,
unsigned int& LineBreaks,
bool& IsDone)
bool findBlockScalarIndent(
unsigned int& BlockIndent,
unsigned int BlockExitIndent,
unsigned int& LineBreaks,
bool& IsDone)
Description
Look for the indentation level of a block scalar. Return false if an error occurred.
Declared at: llvm/lib/Support/YAMLParser.cpp:503
Parameters
- unsigned int& BlockIndent
- unsigned int BlockExitIndent
- unsigned int& LineBreaks
- bool& IsDone
¶llvm::yaml::Token getNext()
llvm::yaml::Token getNext()
Description
Parse the next token and pop it from the queue.
Declared at: llvm/lib/Support/YAMLParser.cpp:259
¶void init(llvm::MemoryBufferRef Buffer)
void init(llvm::MemoryBufferRef Buffer)
Declared at: llvm/lib/Support/YAMLParser.cpp:287
Parameters
- llvm::MemoryBufferRef Buffer
¶bool isBlankOrBreak(StringRef::iterator Position)
bool isBlankOrBreak(StringRef::iterator Position)
Description
Return true if the minimal well-formed code unit subsequence at Pos is whitespace or a new line
Declared at: llvm/lib/Support/YAMLParser.cpp:393
Parameters
- StringRef::iterator Position
¶bool isLineEmpty(llvm::StringRef Line)
bool isLineEmpty(llvm::StringRef Line)
Description
Return true if the line is a line break, false otherwise.
Declared at: llvm/lib/Support/YAMLParser.cpp:396
Parameters
- llvm::StringRef Line
¶llvm::yaml::Token& peekNext()
llvm::yaml::Token& peekNext()
Description
Parse the next token and return it without popping it.
Declared at: llvm/lib/Support/YAMLParser.cpp:256
¶void printError(
llvm::SMLoc Loc,
SourceMgr::DiagKind Kind,
const llvm::Twine& Message,
ArrayRef<llvm::SMRange> Ranges = None)
void printError(
llvm::SMLoc Loc,
SourceMgr::DiagKind Kind,
const llvm::Twine& Message,
ArrayRef<llvm::SMRange> Ranges = None)
Declared at: llvm/lib/Support/YAMLParser.cpp:261
Parameters
- llvm::SMLoc Loc
- SourceMgr::DiagKind Kind
- const llvm::Twine& Message
- ArrayRef<llvm::SMRange> Ranges = None
¶void removeSimpleKeyCandidatesOnFlowLevel(
unsigned int Level)
void removeSimpleKeyCandidatesOnFlowLevel(
unsigned int Level)
Description
Remove all simple keys on FlowLevel \a Level.
Declared at: llvm/lib/Support/YAMLParser.cpp:415
Parameters
- unsigned int Level
¶void removeStaleSimpleKeyCandidates()
void removeStaleSimpleKeyCandidates()
Description
Remove simple keys that can no longer be valid simple keys. Invalid simple keys are not on the current line or are further than 1024 columns back.
Declared at: llvm/lib/Support/YAMLParser.cpp:412
¶bool rollIndent(int ToColumn,
Token::TokenKind Kind,
TokenQueueT::iterator InsertPoint)
bool rollIndent(int ToColumn,
Token::TokenKind Kind,
TokenQueueT::iterator InsertPoint)
Description
Increase indent to \a Col. Creates \a Kind token at \a InsertPoint if needed.
Declared at: llvm/lib/Support/YAMLParser.cpp:423
Parameters
- int ToColumn
- Token::TokenKind Kind
- TokenQueueT::iterator InsertPoint
¶void saveSimpleKeyCandidate(
TokenQueueT::iterator Tok,
unsigned int AtColumn,
bool IsRequired)
void saveSimpleKeyCandidate(
TokenQueueT::iterator Tok,
unsigned int AtColumn,
bool IsRequired)
Description
If IsSimpleKeyAllowed, create and push_back a new SimpleKey.
Declared at: llvm/lib/Support/YAMLParser.cpp:404
Parameters
- TokenQueueT::iterator Tok
- unsigned int AtColumn
- bool IsRequired
¶bool scanAliasOrAnchor(bool IsAlias)
bool scanAliasOrAnchor(bool IsAlias)
Description
Scan an Alias or Anchor starting with * or & .
Declared at: llvm/lib/Support/YAMLParser.cpp:471
Parameters
- bool IsAlias
¶char scanBlockChompingIndicator()
char scanBlockChompingIndicator()
Description
Scan a chomping indicator in a block scalar header.
Declared at: llvm/lib/Support/YAMLParser.cpp:489
¶bool scanBlockEntry()
bool scanBlockEntry()
Description
Scan the - that starts block sequence entries.
Declared at: llvm/lib/Support/YAMLParser.cpp:456
¶unsigned int scanBlockIndentationIndicator()
unsigned int scanBlockIndentationIndicator()
Description
Scan an indentation indicator in a block scalar header.
Declared at: llvm/lib/Support/YAMLParser.cpp:492
¶bool scanBlockScalar(bool IsLiteral)
bool scanBlockScalar(bool IsLiteral)
Description
Scan a block scalar starting with | or >.
Declared at: llvm/lib/Support/YAMLParser.cpp:474
Parameters
- bool IsLiteral
¶bool scanBlockScalarHeader(
char& ChompingIndicator,
unsigned int& IndentIndicator,
bool& IsDone)
bool scanBlockScalarHeader(
char& ChompingIndicator,
unsigned int& IndentIndicator,
bool& IsDone)
Description
Scan a block scalar header. Return false if an error occurred.
Declared at: llvm/lib/Support/YAMLParser.cpp:497
Parameters
- char& ChompingIndicator
- unsigned int& IndentIndicator
- bool& IsDone
¶bool scanBlockScalarIndent(
unsigned int BlockIndent,
unsigned int BlockExitIndent,
bool& IsDone)
bool scanBlockScalarIndent(
unsigned int BlockIndent,
unsigned int BlockExitIndent,
bool& IsDone)
Description
Scan the indentation of a text line in a block scalar. Return false if an error occurred.
Declared at: llvm/lib/Support/YAMLParser.cpp:509
Parameters
- unsigned int BlockIndent
- unsigned int BlockExitIndent
- bool& IsDone
¶bool scanBlockScalarIndicators(
char& StyleIndicator,
char& ChompingIndicator,
unsigned int& IndentIndicator,
bool& IsDone)
bool scanBlockScalarIndicators(
char& StyleIndicator,
char& ChompingIndicator,
unsigned int& IndentIndicator,
bool& IsDone)
Description
Scan a block scalar style indicator and header. Note: This is distinct from scanBlockScalarHeader to mirror the fact that YAML does not consider the style indicator to be a part of the header. Return false if an error occurred.
Declared at: llvm/lib/Support/YAMLParser.cpp:482
Parameters
- char& StyleIndicator
- char& ChompingIndicator
- unsigned int& IndentIndicator
- bool& IsDone
¶char scanBlockStyleIndicator()
char scanBlockStyleIndicator()
Description
Scan a style indicator in a block scalar header.
Declared at: llvm/lib/Support/YAMLParser.cpp:486
¶bool scanDirective()
bool scanDirective()
Description
Scan a %BLAH directive.
Declared at: llvm/lib/Support/YAMLParser.cpp:441
¶bool scanDocumentIndicator(bool IsStart)
bool scanDocumentIndicator(bool IsStart)
Description
Scan a ... or ---.
Declared at: llvm/lib/Support/YAMLParser.cpp:444
Parameters
- bool IsStart
¶bool scanFlowCollectionEnd(bool IsSequence)
bool scanFlowCollectionEnd(bool IsSequence)
Description
Scan a ] or } and generate the proper flow collection end token.
Declared at: llvm/lib/Support/YAMLParser.cpp:450
Parameters
- bool IsSequence
¶bool scanFlowCollectionStart(bool IsSequence)
bool scanFlowCollectionStart(bool IsSequence)
Description
Scan a [ or { and generate the proper flow collection start token.
Declared at: llvm/lib/Support/YAMLParser.cpp:447
Parameters
- bool IsSequence
¶bool scanFlowEntry()
bool scanFlowEntry()
Description
Scan the , that separates entries in a flow collection.
Declared at: llvm/lib/Support/YAMLParser.cpp:453
¶bool scanFlowScalar(bool IsDoubleQuoted)
bool scanFlowScalar(bool IsDoubleQuoted)
Description
Scan a quoted scalar.
Declared at: llvm/lib/Support/YAMLParser.cpp:465
Parameters
- bool IsDoubleQuoted
¶bool scanKey()
bool scanKey()
Description
Scan an explicit ? indicating a key.
Declared at: llvm/lib/Support/YAMLParser.cpp:459
¶bool scanPlainScalar()
bool scanPlainScalar()
Description
Scan an unquoted scalar.
Declared at: llvm/lib/Support/YAMLParser.cpp:468
¶bool scanStreamEnd()
bool scanStreamEnd()
Description
Generate tokens needed to close out the stream.
Declared at: llvm/lib/Support/YAMLParser.cpp:438
¶bool scanStreamStart()
bool scanStreamStart()
Description
Must be the first token generated.
Declared at: llvm/lib/Support/YAMLParser.cpp:435
¶bool scanTag()
bool scanTag()
Description
Scan a tag of the form !stuff.
Declared at: llvm/lib/Support/YAMLParser.cpp:513
¶void scanToNextToken()
void scanToNextToken()
Description
Skip whitespace and comments until the start of the next token.
Declared at: llvm/lib/Support/YAMLParser.cpp:432
¶bool scanValue()
bool scanValue()
Description
Scan an explicit : indicating a value.
Declared at: llvm/lib/Support/YAMLParser.cpp:462
¶void scan_ns_uri_char()
void scan_ns_uri_char()
Description
Scan ns-uri-char[39]s starting at Cur. This updates Cur and Column while scanning.
Declared at: llvm/lib/Support/YAMLParser.cpp:381
¶void setError(const llvm::Twine& Message,
StringRef::iterator Position)
void setError(const llvm::Twine& Message,
StringRef::iterator Position)
Declared at: llvm/lib/Support/YAMLParser.cpp:266
Parameters
- const llvm::Twine& Message
- StringRef::iterator Position
¶void skip(uint32_t Distance)
void skip(uint32_t Distance)
Description
Skip \a Distance UTF-8 code units. Updates \a Cur and \a Column.
Declared at: llvm/lib/Support/YAMLParser.cpp:389
Parameters
- uint32_t Distance
¶void skipComment()
void skipComment()
Description
Skip a single-line comment when the comment starts at the current position of the scanner.
Declared at: llvm/lib/Support/YAMLParser.cpp:429
¶StringRef::iterator skip_b_break(
StringRef::iterator Position)
StringRef::iterator skip_b_break(
StringRef::iterator Position)
Description
Skip a single b-break[28] starting at Position. A b-break is 0xD 0xA | 0xD | 0xA
Declared at: llvm/lib/Support/YAMLParser.cpp:338
Parameters
- StringRef::iterator Position
Returns
The code unit after the b-break, or Position if it's not a b-break.
¶StringRef::iterator skip_nb_char(
StringRef::iterator Position)
StringRef::iterator skip_nb_char(
StringRef::iterator Position)
Description
Skip a single nb-char[27] starting at Position. A nb-char is 0x9 | [0x20-0x7E] | 0x85 | [0xA0-0xD7FF] | [0xE000-0xFEFE] | [0xFF00-0xFFFD] | [0x10000-0x10FFFF]
Declared at: llvm/lib/Support/YAMLParser.cpp:330
Parameters
- StringRef::iterator Position
Returns
The code unit after the nb-char, or Position if it's not an nb-char.
¶StringRef::iterator skip_ns_char(
StringRef::iterator Position)
StringRef::iterator skip_ns_char(
StringRef::iterator Position)
Description
Skip a single ns-char[34] starting at Position. A ns-char is nb-char - s-white
Declared at: llvm/lib/Support/YAMLParser.cpp:362
Parameters
- StringRef::iterator Position
Returns
The code unit after the ns-char, or Position if it's not a ns-char.
¶StringRef::iterator skip_s_space(
StringRef::iterator Position)
StringRef::iterator skip_s_space(
StringRef::iterator Position)
Description
Skip a single s-space[31] starting at Position. An s-space is 0x20
Declared at: llvm/lib/Support/YAMLParser.cpp:346
Parameters
- StringRef::iterator Position
Returns
The code unit after the s-space, or Position if it's not a s-space.
¶StringRef::iterator skip_s_white(
StringRef::iterator Position)
StringRef::iterator skip_s_white(
StringRef::iterator Position)
Description
Skip a single s-white[33] starting at Position. A s-white is 0x20 | 0x9
Declared at: llvm/lib/Support/YAMLParser.cpp:354
Parameters
- StringRef::iterator Position
Returns
The code unit after the s-white, or Position if it's not a s-white.
¶StringRef::iterator skip_while(
llvm::yaml::Scanner::SkipWhileFunc Func,
StringRef::iterator Position)
StringRef::iterator skip_while(
llvm::yaml::Scanner::SkipWhileFunc Func,
StringRef::iterator Position)
Description
Skip minimal well-formed code unit subsequences until Func returns its input.
Declared at: llvm/lib/Support/YAMLParser.cpp:371
Parameters
- llvm::yaml::Scanner::SkipWhileFunc Func
- StringRef::iterator Position
Returns
The code unit after the last minimal well-formed code unit subsequence that Func accepted.
¶bool unrollIndent(int ToColumn)
bool unrollIndent(int ToColumn)
Description
Unroll indentation in \a Indents back to \a Col. Creates BlockEnd tokens if needed.
Declared at: llvm/lib/Support/YAMLParser.cpp:419
Parameters
- int ToColumn