A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
detail::parser< BasicJsonType, InputAdapterType > Class Template Reference

syntax analysis More...

+ Collaboration diagram for detail::parser< BasicJsonType, InputAdapterType >:

Public Member Functions

 parser (InputAdapterType &&adapter, parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool ignore_comments=false, const bool ignore_trailing_commas_=false)
 a parser reading from an input adapter
 
bool accept (const bool strict=true)
 public accept interface
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface
 
template<typename SAX >
bool sax_parse (SAX *sax, const bool strict=true)
 

Private Types

using lexer_t = lexer< BasicJsonType, InputAdapterType >
 
using number_float_t = typename BasicJsonType::number_float_t
 
using number_integer_t = typename BasicJsonType::number_integer_t
 
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
 
using string_t = typename BasicJsonType::string_t
 
using token_type = typename lexer_t::token_type
 

Private Member Functions

std::string exception_message (const token_type expected, const std::string &context)
 
token_type get_token ()
 get next token from lexer
 
template<typename SAX >
bool sax_parse_internal (SAX *sax)
 

Private Attributes

const bool allow_exceptions = true
 whether to throw exceptions in case of errors
 
const parser_callback_t< BasicJsonType > callback = nullptr
 callback function
 
const bool ignore_trailing_commas = false
 whether trailing commas in objects and arrays should be ignored (true) or signaled as errors (false)
 
token_type last_token = token_type::uninitialized
 the type of the last read token
 
lexer_t m_lexer
 the lexer
 

Detailed Description

template<typename BasicJsonType, typename InputAdapterType>
class detail::parser< BasicJsonType, InputAdapterType >

syntax analysis

This class implements a recursive descent parser.

Definition at line 12979 of file json.h.

Member Typedef Documentation

◆ lexer_t

template<typename BasicJsonType , typename InputAdapterType >
using detail::parser< BasicJsonType, InputAdapterType >::lexer_t = lexer<BasicJsonType, InputAdapterType>
private

Definition at line 12985 of file json.h.

◆ number_float_t

template<typename BasicJsonType , typename InputAdapterType >
using detail::parser< BasicJsonType, InputAdapterType >::number_float_t = typename BasicJsonType::number_float_t
private

Definition at line 12983 of file json.h.

◆ number_integer_t

template<typename BasicJsonType , typename InputAdapterType >
using detail::parser< BasicJsonType, InputAdapterType >::number_integer_t = typename BasicJsonType::number_integer_t
private

Definition at line 12981 of file json.h.

◆ number_unsigned_t

template<typename BasicJsonType , typename InputAdapterType >
using detail::parser< BasicJsonType, InputAdapterType >::number_unsigned_t = typename BasicJsonType::number_unsigned_t
private

Definition at line 12982 of file json.h.

◆ string_t

template<typename BasicJsonType , typename InputAdapterType >
using detail::parser< BasicJsonType, InputAdapterType >::string_t = typename BasicJsonType::string_t
private

Definition at line 12984 of file json.h.

◆ token_type

template<typename BasicJsonType , typename InputAdapterType >
using detail::parser< BasicJsonType, InputAdapterType >::token_type = typename lexer_t::token_type
private

Definition at line 12986 of file json.h.

Constructor & Destructor Documentation

◆ parser()

template<typename BasicJsonType , typename InputAdapterType >
detail::parser< BasicJsonType, InputAdapterType >::parser ( InputAdapterType &&  adapter,
parser_callback_t< BasicJsonType >  cb = nullptr,
const bool  allow_exceptions_ = true,
const bool  ignore_comments = false,
const bool  ignore_trailing_commas_ = false 
)
inlineexplicit

a parser reading from an input adapter

Definition at line 12990 of file json.h.

Member Function Documentation

◆ accept()

template<typename BasicJsonType , typename InputAdapterType >
bool detail::parser< BasicJsonType, InputAdapterType >::accept ( const bool  strict = true)
inline

public accept interface

Parameters
[in]strictwhether to expect the last token to be EOF
Returns
whether the input is a proper JSON text

Definition at line 13074 of file json.h.

References detail::strict.

◆ exception_message()

template<typename BasicJsonType , typename InputAdapterType >
std::string detail::parser< BasicJsonType, InputAdapterType >::exception_message ( const token_type  expected,
const std::string &  context 
)
inlineprivate

Definition at line 13412 of file json.h.

References detail::concat().

+ Here is the call graph for this function:

◆ get_token()

template<typename BasicJsonType , typename InputAdapterType >
token_type detail::parser< BasicJsonType, InputAdapterType >::get_token ( )
inlineprivate

get next token from lexer

Definition at line 13407 of file json.h.

◆ parse()

template<typename BasicJsonType , typename InputAdapterType >
void detail::parser< BasicJsonType, InputAdapterType >::parse ( const bool  strict,
BasicJsonType &  result 
)
inline

public parser interface

Parameters
[in]strictwhether to expect the last token to be EOF
[in,out]resultparsed JSON value
Exceptions
parse_error.101in case of an unexpected token
parse_error.102if to_unicode fails or surrogate error
parse_error.103if to_unicode fails

Definition at line 13014 of file json.h.

References detail::json_sax_dom_parser< BasicJsonType, InputAdapterType >::is_errored(), detail::json_sax_dom_callback_parser< BasicJsonType, InputAdapterType >::is_errored(), detail::json_sax_dom_parser< BasicJsonType, InputAdapterType >::parse_error(), detail::json_sax_dom_callback_parser< BasicJsonType, InputAdapterType >::parse_error(), and detail::strict.

+ Here is the call graph for this function:

◆ sax_parse()

template<typename BasicJsonType , typename InputAdapterType >
template<typename SAX >
bool detail::parser< BasicJsonType, InputAdapterType >::sax_parse ( SAX *  sax,
const bool  strict = true 
)
inline

Definition at line 13082 of file json.h.

References detail::strict.

◆ sax_parse_internal()

template<typename BasicJsonType , typename InputAdapterType >
template<typename SAX >
bool detail::parser< BasicJsonType, InputAdapterType >::sax_parse_internal ( SAX *  sax)
inlineprivate

Definition at line 13101 of file json.h.

References detail::concat(), JSON_ASSERT, JSON_HEDLEY_LIKELY, JSON_HEDLEY_UNLIKELY, and detail::unknown_size().

+ Here is the call graph for this function:

Member Data Documentation

◆ allow_exceptions

template<typename BasicJsonType , typename InputAdapterType >
const bool detail::parser< BasicJsonType, InputAdapterType >::allow_exceptions = true
private

whether to throw exceptions in case of errors

Definition at line 13449 of file json.h.

◆ callback

template<typename BasicJsonType , typename InputAdapterType >
const parser_callback_t<BasicJsonType> detail::parser< BasicJsonType, InputAdapterType >::callback = nullptr
private

callback function

Definition at line 13443 of file json.h.

◆ ignore_trailing_commas

template<typename BasicJsonType , typename InputAdapterType >
const bool detail::parser< BasicJsonType, InputAdapterType >::ignore_trailing_commas = false
private

whether trailing commas in objects and arrays should be ignored (true) or signaled as errors (false)

Definition at line 13451 of file json.h.

◆ last_token

template<typename BasicJsonType , typename InputAdapterType >
token_type detail::parser< BasicJsonType, InputAdapterType >::last_token = token_type::uninitialized
private

the type of the last read token

Definition at line 13445 of file json.h.

◆ m_lexer

template<typename BasicJsonType , typename InputAdapterType >
lexer_t detail::parser< BasicJsonType, InputAdapterType >::m_lexer
private

the lexer

Definition at line 13447 of file json.h.


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