A ScannedTokens adaptor that provides a traditional scanner API. More...
#include <ScannedTokens.hpp>
Classes | |
class | Marker |
A position marker that can be obtained at any point during parsing, in order to put back multiple tokens. More... | |
Public Member Functions | |
ScannerApiScannedTokens (ScannedTokens< TokenT > &&scannedTokens_) noexcept | |
Create a scanner API scanned tokens instance. More... | |
void | consume () |
Consume the current token. More... | |
bool | currentIsBlank () const |
Is the next token a blank? More... | |
bool | currentIsLineBreak () const |
Is the next token line break? More... | |
bool | currentIsWhitespace () const |
Is the next token whitespace? More... | |
void | expect (const TokenT token, std::string_view errorMessage) |
Expect the supplied token. More... | |
template<template< typename ... > class ContainerT, typename ... ArgT, typename ReportT > | |
bool | expect (const TokenT token, ContainerT< ReportT, ArgT ... > &container, const size_t maxErrorCount, const std::function< ReportT(const TokenT &, const CodeSpan &, size_t)> &errorReport) |
Expect the supplied token. More... | |
void | expect (const std::vector< TokenT > &tokens, std::string_view errorMessage) |
Expect one of the supplied tokens. More... | |
template<template< typename ... > class TokenContainerT, template< typename ... > class ContainerT, typename ... TokenArgT, typename ... ArgT, typename ReportT > | |
bool | expect (const TokenContainerT< TokenT, TokenArgT ... > &tokens, ContainerT< ReportT, ArgT ... > &container, const size_t maxErrorCount, const std::function< ReportT(const TokenContainerT< TokenT, TokenArgT ... > &, const CodeSpan &, size_t)> &errorReport) |
Expect one of the supplied tokens. More... | |
ScannedToken< TokenT > | get () |
Get the current token. More... | |
CodeSpan | getCurrentCodeSpan () const |
Get the code span of the current token. More... | |
std::shared_ptr< const Resource::Uri > | getUri () |
Move the input uri to its final destination. More... | |
bool | isBlank (const Marker &marker) const |
Is the marked token a blank? More... | |
bool | isLineBreak (const Marker &marker) const |
Is the marked token line break? More... | |
bool | isWhitespace (const Marker &marker) const |
Is the marked token whitespace? More... | |
std::string && | moveTextOut () |
Move the input text string to its final destination. More... | |
void | popWhitespaceMode () |
Pop the top of the whitespace mode stack. More... | |
void | pushWhitespaceMode (WhitespaceMode newMode) |
Push the supplied whitespace mode onto the whitespace mode stack. More... | |
void | putBack () |
Put back the current token. More... | |
void | reset () |
Rest the scanner API state to the beginning of the scanned tokens. More... | |
size_t | size () const |
Get the number of tokens. More... | |
A ScannedTokens adaptor that provides a traditional scanner API.
|
inlineexplicitnoexcept |
Create a scanner API scanned tokens instance.
|
inline |
Consume the current token.
If the current token is EndOfFile, then no action is taken.
|
inline |
Is the next token a blank?
|
inline |
Is the next token line break?
|
inline |
Is the next token whitespace?
|
inline |
Expect the supplied token.
Throws a syntax error exception with the supplied error message if the supplied token does not match the current token.
token | the expected token |
errorMessage | an error message to pass to the exception |
SyntaxErrorException | if the token was not found |
|
inline |
Expect the supplied token.
Adds an error report to the supplied error report container and returns false if the supplied token does not match the current token.
The current error count is also passed to the error report generation function in order to allow a generic report to be generated when the container contains the maximum number of errors.
token | the expected token |
container | the error report container to add the error report to |
maxErrorCount | the maximum number of errors that the container is allowed to have |
errorReport | a function that generates the error report |
|
inline |
Expect one of the supplied tokens.
Throws a syntax error exception with the supplied error message if none of the supplied tokens match the current token.
SyntaxErrorException | if one of the tokens was not found |
|
inline |
Expect one of the supplied tokens.
Adds an error report to the supplied error report container and returns false if none of the supplied tokens match the current token.
The current error count is also passed to the error report generation function in order to allow a generic report to be generated when the container contains the maximum number of errors.
token | the expected token |
container | the error report container to add the error report to |
maxErrorCount | the maximum number of errors that the container is allowed to have |
errorReport | a function that generates the error report |
|
inline |
Get the current token.
Depending on the whitespace mode, this may skip over whitespace and/or line break tokens.
|
inline |
Get the code span of the current token.
|
inline |
Move the input uri to its final destination.
|
inline |
Is the marked token a blank?
|
inline |
Is the marked token line break?
|
inline |
Is the marked token whitespace?
|
inline |
Move the input text string to its final destination.
The scanned tokens instance must not be used after the move is performed.
|
inline |
Pop the top of the whitespace mode stack.
|
inline |
Push the supplied whitespace mode onto the whitespace mode stack.
|
inline |
Put back the current token.
Depending on the whitespace mode, this may also reverse skip whitespace and/or line break tokens.
|
inline |
Rest the scanner API state to the beginning of the scanned tokens.
|
inline |
Get the number of tokens.