AsmGrader 0.0.0
Loading...
Searching...
No Matches
asmgrader::inspection::tokenize::Stream Class Reference

#include <expression_inspection.hpp>

Classes

struct  StreamContext
 Primarily used to support Token::Kind::Grouping. More...
 

Public Member Functions

constexpr explicit (false) Stream(const char *string)
 
constexpr explicit (false) Stream(std
 
constexpr Stream (std::string_view string, StreamContext context)
 This overload is just used for writing tests.
 
constexpr std::size_t size () const
 
constexpr bool empty () const
 
constexpr char peek () const
 Peek at the first character of the stream.
 
constexpr std::string_view peek (std::size_t n) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Peek at the first n characters of the stream.
 
constexpr std::string_view peek_until (auto what) const
 substr_to
 
constexpr std::string_view peek_while (std::invocable< char > auto pred) const
 
constexpr std::string_view peek_through (auto what) const
 
constexpr std::string_view peek_past (auto what) const
 substr_past
 
constexpr std::string_view consume (std::size_t n)
 Same as peek, except it also mutates the stream.
 
template<typename StrLike >
requires std::convertible_to<StrLike, std::string_view> || std::same_as<StrLike, char>
constexpr bool consume (StrLike str)
 Attempt to consume str at the beginning of the stream, iff it actually exists at the beginning.
 
constexpr bool consume (auto what, CaseInsensitiveTag)
 
constexpr std::string_view consume_until (auto what)
 Same as peek_until, except it also mutates the stream.
 
constexpr std::string_view consume_through (auto what)
 Same as peek_through, except it also mutates the stream.
 
constexpr std::string_view consume_while (std::invocable< char > auto pred)
 Same as peek_while, except it also mutates the stream.
 
constexpr bool starts_with (auto what) const
 Whether the stream starts with what (accepts same as std::string_view::starts_with)
 
constexpr bool starts_with (char chr, CaseInsensitiveTag) const
 
constexpr bool starts_with (std::string_view string, CaseInsensitiveTag) const
 
constexpr std::string_view str () const
 

Public Attributes

StreamContext ctx {}
 

Constructor & Destructor Documentation

◆ Stream()

asmgrader::inspection::tokenize::Stream::Stream ( std::string_view string,
StreamContext context )
inlineconstexpr

This overload is just used for writing tests.

Member Function Documentation

◆ consume() [1/3]

bool asmgrader::inspection::tokenize::Stream::consume ( auto what,
CaseInsensitiveTag  )
inlineconstexpr

◆ consume() [2/3]

std::string_view asmgrader::inspection::tokenize::Stream::consume ( std::size_t n)
inlineconstexpr

Same as peek, except it also mutates the stream.

◆ consume() [3/3]

template<typename StrLike >
requires std::convertible_to<StrLike, std::string_view> || std::same_as<StrLike, char>
bool asmgrader::inspection::tokenize::Stream::consume ( StrLike str)
inlineconstexpr

Attempt to consume str at the beginning of the stream, iff it actually exists at the beginning.

Parameters
strEither a string or char to attempt to consume
Returns
Whether str was successfully consumed

◆ consume_through()

std::string_view asmgrader::inspection::tokenize::Stream::consume_through ( auto what)
inlineconstexpr

Same as peek_through, except it also mutates the stream.

◆ consume_until()

std::string_view asmgrader::inspection::tokenize::Stream::consume_until ( auto what)
inlineconstexpr

Same as peek_until, except it also mutates the stream.

◆ consume_while()

std::string_view asmgrader::inspection::tokenize::Stream::consume_while ( std::invocable< char > auto pred)
inlineconstexpr

Same as peek_while, except it also mutates the stream.

◆ empty()

bool asmgrader::inspection::tokenize::Stream::empty ( ) const
inlineconstexpr

◆ explicit() [1/2]

asmgrader::inspection::tokenize::Stream::explicit ( false ) const
inlineconstexpr

◆ explicit() [2/2]

asmgrader::inspection::tokenize::Stream::explicit ( false )
inlineconstexpr

◆ peek() [1/2]

char asmgrader::inspection::tokenize::Stream::peek ( ) const
inlineconstexpr

Peek at the first character of the stream.

◆ peek() [2/2]

std::string_view asmgrader::inspection::tokenize::Stream::peek ( std::size_t n) const
inlineconstexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Peek at the first n characters of the stream.

◆ peek_past()

std::string_view asmgrader::inspection::tokenize::Stream::peek_past ( auto what) const
inlineconstexpr

◆ peek_through()

std::string_view asmgrader::inspection::tokenize::Stream::peek_through ( auto what) const
inlineconstexpr

◆ peek_until()

std::string_view asmgrader::inspection::tokenize::Stream::peek_until ( auto what) const
inlineconstexpr

◆ peek_while()

std::string_view asmgrader::inspection::tokenize::Stream::peek_while ( std::invocable< char > auto pred) const
inlineconstexpr

◆ size()

std::size_t asmgrader::inspection::tokenize::Stream::size ( ) const
inlineconstexpr

◆ starts_with() [1/3]

bool asmgrader::inspection::tokenize::Stream::starts_with ( auto what) const
inlineconstexpr

Whether the stream starts with what (accepts same as std::string_view::starts_with)

◆ starts_with() [2/3]

bool asmgrader::inspection::tokenize::Stream::starts_with ( char chr,
CaseInsensitiveTag  ) const
inlineconstexpr

◆ starts_with() [3/3]

bool asmgrader::inspection::tokenize::Stream::starts_with ( std::string_view string,
CaseInsensitiveTag  ) const
inlineconstexpr

◆ str()

std::string_view asmgrader::inspection::tokenize::Stream::str ( ) const
inlineconstexpr

Member Data Documentation

◆ ctx

StreamContext asmgrader::inspection::tokenize::Stream::ctx {}

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