Free Electron
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
YAML::Scanner Class Reference

A scanner transforms a stream of characters into a stream of tokens. More...

#include <scanner.h>

Public Member Functions

 Scanner (std::istream &in)
 
bool empty ()
 Returns true if there are no more tokens to be read. More...
 
void pop ()
 Removes the next token in the queue. More...
 
Token & peek ()
 Returns, but does not remove, the next token in the queue. More...
 
Mark mark () const
 Returns the current mark in the input stream. More...
 

Private Types

enum  FLOW_MARKER {
  FLOW_MAP,
  FLOW_SEQ
}
 

Private Member Functions

void EnsureTokensInQueue ()
 Scans until there's a valid token at the front of the queue, or the queue is empty. More...
 
void ScanNextToken ()
 The main scanning function; this method branches out to scan whatever the next token should be. More...
 
void ScanToNextToken ()
 Eats the input stream until it reaches the next token-like thing. More...
 
void StartStream ()
 Sets the initial conditions for starting a stream. More...
 
void EndStream ()
 Closes out the stream, finish up, etc. More...
 
Token * PushToken (Token::TYPE type)
 
bool InFlowContext () const
 
bool InBlockContext () const
 
std::size_t GetFlowLevel () const
 
Token::TYPE GetStartTokenFor (IndentMarker::INDENT_TYPE type) const
 
IndentMarker * PushIndentTo (int column, IndentMarker::INDENT_TYPE type)
 Pushes an indentation onto the stack, and enqueues the proper token (sequence start or mapping start). More...
 
void PopIndentToHere ()
 Pops indentations off the stack until it reaches the current indentation level, and enqueues the proper token each time. More...
 
void PopAllIndents ()
 Pops all indentations (except for the base empty one) off the stack, and enqueues the proper token each time. More...
 
void PopIndent ()
 Pops a single indent, pushing the proper token. More...
 
int GetTopIndent () const
 
bool CanInsertPotentialSimpleKey () const
 
bool ExistsActiveSimpleKey () const
 
void InsertPotentialSimpleKey ()
 
void InvalidateSimpleKey ()
 
bool VerifySimpleKey ()
 
void PopAllSimpleKeys ()
 
void ThrowParserException (const std::string &msg) const
 Throws a ParserException with the current token location (if available), and does not parse any more tokens. More...
 
bool IsWhitespaceToBeEaten (char ch)
 
const RegEx & GetValueRegex () const
 Returns the appropriate regex to check if the next token is a value token. More...
 
void ScanDirective ()
 
void ScanDocStart ()
 
void ScanDocEnd ()
 
void ScanBlockSeqStart ()
 
void ScanBlockMapSTart ()
 
void ScanBlockEnd ()
 
void ScanBlockEntry ()
 
void ScanFlowStart ()
 
void ScanFlowEnd ()
 
void ScanFlowEntry ()
 
void ScanKey ()
 
void ScanValue ()
 
void ScanAnchorOrAlias ()
 
void ScanTag ()
 
void ScanPlainScalar ()
 
void ScanQuotedScalar ()
 
void ScanBlockScalar ()
 

Private Attributes

Stream INPUT
 
std::queue< Token > m_tokens
 
bool m_startedStream
 
bool m_endedStream
 
bool m_simpleKeyAllowed
 
bool m_canBeJSONFlow
 
std::stack< SimpleKey > m_simpleKeys
 
std::stack< IndentMarker * > m_indents
 
ptr_vector< IndentMarker > m_indentRefs
 
std::stack< FLOW_MARKER > m_flows
 

Detailed Description

A scanner transforms a stream of characters into a stream of tokens.

Member Function Documentation

◆ empty()

bool YAML::Scanner::empty ( )

Returns true if there are no more tokens to be read.

◆ EndStream()

void YAML::Scanner::EndStream ( )
private

Closes out the stream, finish up, etc.

◆ EnsureTokensInQueue()

void YAML::Scanner::EnsureTokensInQueue ( )
private

Scans until there's a valid token at the front of the queue, or the queue is empty.

The state can be checked by empty, and the next token retrieved by peek.

◆ GetValueRegex()

const RegEx& YAML::Scanner::GetValueRegex ( ) const
private

Returns the appropriate regex to check if the next token is a value token.

◆ mark()

Mark YAML::Scanner::mark ( ) const

Returns the current mark in the input stream.

◆ peek()

Token& YAML::Scanner::peek ( )

Returns, but does not remove, the next token in the queue.

◆ pop()

void YAML::Scanner::pop ( )

Removes the next token in the queue.

◆ PopAllIndents()

void YAML::Scanner::PopAllIndents ( )
private

Pops all indentations (except for the base empty one) off the stack, and enqueues the proper token each time.

◆ PopIndent()

void YAML::Scanner::PopIndent ( )
private

Pops a single indent, pushing the proper token.

◆ PopIndentToHere()

void YAML::Scanner::PopIndentToHere ( )
private

Pops indentations off the stack until it reaches the current indentation level, and enqueues the proper token each time.

Then pops all invalid indentations off.

◆ PushIndentTo()

IndentMarker* YAML::Scanner::PushIndentTo ( int  column,
IndentMarker::INDENT_TYPE  type 
)
private

Pushes an indentation onto the stack, and enqueues the proper token (sequence start or mapping start).

Returns
the indent marker it generates (if any).

◆ ScanNextToken()

void YAML::Scanner::ScanNextToken ( )
private

The main scanning function; this method branches out to scan whatever the next token should be.

◆ ScanToNextToken()

void YAML::Scanner::ScanToNextToken ( )
private

Eats the input stream until it reaches the next token-like thing.

◆ StartStream()

void YAML::Scanner::StartStream ( )
private

Sets the initial conditions for starting a stream.

◆ ThrowParserException()

void YAML::Scanner::ThrowParserException ( const std::string &  msg) const
private

Throws a ParserException with the current token location (if available), and does not parse any more tokens.


The documentation for this class was generated from the following file: