GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::json::Lexer< It, Allocator > Class Template Reference

Lexical analyzer for scanning and tokenizing input in the JSON5 format. More...

#include <GREM/core/formats/json.hpp>

Public Types

using allocator_type = Allocator<VariantBase<Allocator>>
 Allocator type used by the lexer.
using Token = TokenBase<Allocator>
 Token type of the lexer.

Public Member Functions

 Lexer (unicode::UTF8Iterator< It > it, unicode::UTF8Sentinel end, const SourceLocation &source, const allocator_type &allocator=allocator_type())
 Construct a lexer with a Unicode iterator pair as input.
 Lexer (const Lexer &other, const allocator_type &allocator)
 Copy constructor.
 Lexer (Lexer &&other, const allocator_type &allocator) noexcept
 Move constructor.
 ~Lexer ()=default
 Destructor.
 Lexer (const Lexer &other)
 Copy constructor.
 Lexer (Lexer &&other) noexcept
 Move constructor.
Lexer & operator= (const Lexer &other)
 Copy assignment.
Lexer & operator= (Lexer &&other) noexcept
 Move assignment.
allocator_type get_allocator () const noexcept
 Get the allocator used by the lexer.
Token scan ()
 Scan and consume the next token from the input.

Detailed Description

template<typename It, template< typename > typename Allocator = std::allocator>
class grem::json::Lexer< It, Allocator >

Lexical analyzer for scanning and tokenizing input in the JSON5 format.

Template Parameters
Ititerator type of the underlying input source. Must be an input iterator.

Member Typedef Documentation

◆ allocator_type

template<typename It, template< typename > typename Allocator = std::allocator>
using grem::json::Lexer< It, Allocator >::allocator_type = Allocator<VariantBase<Allocator>>

Allocator type used by the lexer.

◆ Token

template<typename It, template< typename > typename Allocator = std::allocator>
using grem::json::Lexer< It, Allocator >::Token = TokenBase<Allocator>

Token type of the lexer.

Constructor & Destructor Documentation

◆ Lexer() [1/5]

template<typename It, template< typename > typename Allocator = std::allocator>
grem::json::Lexer< It, Allocator >::Lexer ( unicode::UTF8Iterator< It > it,
unicode::UTF8Sentinel end,
const SourceLocation & source,
const allocator_type & allocator = allocator_type() )
inline

Construct a lexer with a Unicode iterator pair as input.

Parameters
ititerator to the beginning of the JSON input to scan.
endsentinel that marks the end of the JSON input to scan.
sourceinitial source location corresponding to the current position of the iterator.
allocatorallocator to use.
Warning
The iterator pair [it, end) must form a valid forward range.

◆ Lexer() [2/5]

template<typename It, template< typename > typename Allocator = std::allocator>
grem::json::Lexer< It, Allocator >::Lexer ( const Lexer< It, Allocator > & other,
const allocator_type & allocator )
inline

Copy constructor.

◆ Lexer() [3/5]

template<typename It, template< typename > typename Allocator = std::allocator>
grem::json::Lexer< It, Allocator >::Lexer ( Lexer< It, Allocator > && other,
const allocator_type & allocator )
inlinenoexcept

Move constructor.

◆ ~Lexer()

template<typename It, template< typename > typename Allocator = std::allocator>
grem::json::Lexer< It, Allocator >::~Lexer ( )
default

Destructor.

◆ Lexer() [4/5]

template<typename It, template< typename > typename Allocator = std::allocator>
grem::json::Lexer< It, Allocator >::Lexer ( const Lexer< It, Allocator > & other)
inline

Copy constructor.

◆ Lexer() [5/5]

template<typename It, template< typename > typename Allocator = std::allocator>
grem::json::Lexer< It, Allocator >::Lexer ( Lexer< It, Allocator > && other)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename It, template< typename > typename Allocator = std::allocator>
Lexer & grem::json::Lexer< It, Allocator >::operator= ( const Lexer< It, Allocator > & other)
inline

Copy assignment.

◆ operator=() [2/2]

template<typename It, template< typename > typename Allocator = std::allocator>
Lexer & grem::json::Lexer< It, Allocator >::operator= ( Lexer< It, Allocator > && other)
inlinenoexcept

Move assignment.

◆ get_allocator()

template<typename It, template< typename > typename Allocator = std::allocator>
allocator_type grem::json::Lexer< It, Allocator >::get_allocator ( ) const
inlinenodiscardnoexcept

Get the allocator used by the lexer.

Returns
a copy of the lexer's allocator.

◆ scan()

template<typename It, template< typename > typename Allocator = std::allocator>
Token grem::json::Lexer< It, Allocator >::scan ( )
inline

Scan and consume the next token from the input.

This advances the internal state of the lexer.

Returns
the scanned token.
Exceptions
json::Erroron invalid input.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
anyexception thrown by the underlying input iterator.

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