SciLex
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
scilex::lex_error Class Reference

Thrown when no rule matches at a position (a lexical error). More...

#include <lexer.hpp>

Inheritance diagram for scilex::lex_error:
[legend]
Collaboration diagram for scilex::lex_error:
[legend]

Public Member Functions

 lex_error (const std::string &message, position where)
 Builds the error.
 
 lex_error (const std::string &message, position where, std::vector< token > decided)
 Builds the error a stream raises after deciding tokens in the same call.
 
position where () const noexcept
 Returns the position of the unmatched byte.
 
const std::vector< token > & decided () const noexcept
 The tokens a token_stream call decided before the error, in order: with the tokens its earlier calls returned, every token before the error, wherever the text was cut. Empty from lexer::tokenize.
 

Detailed Description

Thrown when no rule matches at a position (a lexical error).

Carries the position of the offending byte so a caller can report it.

Constructor & Destructor Documentation

◆ lex_error() [1/2]

scilex::lex_error::lex_error ( const std::string &  message,
position  where 
)
inline

Builds the error.

Parameters
[in]messageHuman-readable cause.
[in]wherePosition of the byte that no rule could match.

◆ lex_error() [2/2]

scilex::lex_error::lex_error ( const std::string &  message,
position  where,
std::vector< token >  decided 
)
inline

Builds the error a stream raises after deciding tokens in the same call.

Parameters
[in]messageHuman-readable cause.
[in]wherePosition of the byte that no rule could match.
[in]decidedThe tokens the call decided before it, in order.

Member Function Documentation

◆ decided()

const std::vector< token > & scilex::lex_error::decided ( ) const
inlinenoexcept

The tokens a token_stream call decided before the error, in order: with the tokens its earlier calls returned, every token before the error, wherever the text was cut. Empty from lexer::tokenize.

Returns
The tokens; a lexeme views the stream's buffer, valid until its next call.

◆ where()

position scilex::lex_error::where ( ) const
inlinenoexcept

Returns the position of the unmatched byte.


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