added compliance test cases
This commit is contained in:
parent
9f9d293bad
commit
869035a6c9
39 changed files with 240 additions and 27 deletions
50
src/json.hpp
50
src/json.hpp
|
|
@ -3631,7 +3631,7 @@ class basic_json
|
|||
static const unsigned char yybm[] =
|
||||
{
|
||||
0, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 96, 96, 64, 64, 96, 64, 64,
|
||||
64, 32, 32, 64, 64, 32, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64,
|
||||
96, 64, 0, 64, 64, 64, 64, 64,
|
||||
|
|
@ -3914,11 +3914,26 @@ basic_json_parser_25:
|
|||
basic_json_parser_26:
|
||||
yyaccept = 0;
|
||||
yych = *(m_marker = ++m_cursor);
|
||||
if (yych <= 0x00)
|
||||
if (yych <= '\n')
|
||||
{
|
||||
if (yych <= 0x00)
|
||||
{
|
||||
goto basic_json_parser_19;
|
||||
}
|
||||
if (yych <= 0x08)
|
||||
{
|
||||
goto basic_json_parser_31;
|
||||
}
|
||||
goto basic_json_parser_19;
|
||||
}
|
||||
goto basic_json_parser_31;
|
||||
else
|
||||
{
|
||||
if (yych == '\r')
|
||||
{
|
||||
goto basic_json_parser_19;
|
||||
}
|
||||
goto basic_json_parser_31;
|
||||
}
|
||||
basic_json_parser_27:
|
||||
++m_cursor;
|
||||
{
|
||||
|
|
@ -3939,7 +3954,7 @@ basic_json_parser_31:
|
|||
{
|
||||
goto basic_json_parser_30;
|
||||
}
|
||||
if (yych <= 0x00)
|
||||
if (yych <= '\r')
|
||||
{
|
||||
goto basic_json_parser_32;
|
||||
}
|
||||
|
|
@ -4395,7 +4410,7 @@ basic_json_parser_59:
|
|||
m_buffer.erase(0, static_cast<size_t>(offset_start));
|
||||
std::string line;
|
||||
std::getline(*m_stream, line);
|
||||
m_buffer += line;
|
||||
m_buffer += "\n" + line; // add line with newline symbol
|
||||
|
||||
m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
|
||||
m_start = m_content;
|
||||
|
|
@ -4641,6 +4656,9 @@ basic_json_parser_59:
|
|||
return result;
|
||||
}
|
||||
|
||||
// no comma is expected here
|
||||
unexpect(lexer::token_type::value_separator);
|
||||
|
||||
// otherwise: parse key-value pairs
|
||||
do
|
||||
{
|
||||
|
|
@ -4707,6 +4725,9 @@ basic_json_parser_59:
|
|||
return result;
|
||||
}
|
||||
|
||||
// no comma is expected here
|
||||
unexpect(lexer::token_type::value_separator);
|
||||
|
||||
// otherwise: parse values
|
||||
do
|
||||
{
|
||||
|
|
@ -4796,11 +4817,8 @@ basic_json_parser_59:
|
|||
|
||||
default:
|
||||
{
|
||||
std::string error_msg = "parse error - unexpected \'";
|
||||
error_msg += m_lexer.get_token();
|
||||
error_msg += "\' (";
|
||||
error_msg += lexer::token_type_name(last_token) + ")";
|
||||
throw std::invalid_argument(error_msg);
|
||||
// the last token was unexpected
|
||||
unexpect(last_token);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4830,6 +4848,18 @@ basic_json_parser_59:
|
|||
}
|
||||
}
|
||||
|
||||
inline void unexpect(typename lexer::token_type t) const
|
||||
{
|
||||
if (t == last_token)
|
||||
{
|
||||
std::string error_msg = "parse error - unexpected \'";
|
||||
error_msg += m_lexer.get_token();
|
||||
error_msg += "\' (";
|
||||
error_msg += lexer::token_type_name(last_token) + ")";
|
||||
throw std::invalid_argument(error_msg);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/// levels of recursion
|
||||
int depth = 0;
|
||||
|
|
|
|||
|
|
@ -3669,7 +3669,7 @@ class basic_json
|
|||
// string
|
||||
quotation_mark = [\"];
|
||||
escape = [\\];
|
||||
unescaped = [^\"\\\000];
|
||||
unescaped = [^\"\\\000\t\n\r];
|
||||
single_escaped = [\"\\/bfnrt];
|
||||
unicode_escaped = [u][0-9a-fA-F]{4};
|
||||
escaped = escape (single_escaped | unicode_escaped);
|
||||
|
|
@ -3701,7 +3701,7 @@ class basic_json
|
|||
m_buffer.erase(0, static_cast<size_t>(offset_start));
|
||||
std::string line;
|
||||
std::getline(*m_stream, line);
|
||||
m_buffer += line;
|
||||
m_buffer += "\n" + line; // add line with newline symbol
|
||||
|
||||
m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
|
||||
m_start = m_content;
|
||||
|
|
@ -3947,6 +3947,9 @@ class basic_json
|
|||
return result;
|
||||
}
|
||||
|
||||
// no comma is expected here
|
||||
unexpect(lexer::token_type::value_separator);
|
||||
|
||||
// otherwise: parse key-value pairs
|
||||
do
|
||||
{
|
||||
|
|
@ -4013,6 +4016,9 @@ class basic_json
|
|||
return result;
|
||||
}
|
||||
|
||||
// no comma is expected here
|
||||
unexpect(lexer::token_type::value_separator);
|
||||
|
||||
// otherwise: parse values
|
||||
do
|
||||
{
|
||||
|
|
@ -4102,11 +4108,8 @@ class basic_json
|
|||
|
||||
default:
|
||||
{
|
||||
std::string error_msg = "parse error - unexpected \'";
|
||||
error_msg += m_lexer.get_token();
|
||||
error_msg += "\' (";
|
||||
error_msg += lexer::token_type_name(last_token) + ")";
|
||||
throw std::invalid_argument(error_msg);
|
||||
// the last token was unexpected
|
||||
unexpect(last_token);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4136,6 +4139,18 @@ class basic_json
|
|||
}
|
||||
}
|
||||
|
||||
inline void unexpect(typename lexer::token_type t) const
|
||||
{
|
||||
if (t == last_token)
|
||||
{
|
||||
std::string error_msg = "parse error - unexpected \'";
|
||||
error_msg += m_lexer.get_token();
|
||||
error_msg += "\' (";
|
||||
error_msg += lexer::token_type_name(last_token) + ")";
|
||||
throw std::invalid_argument(error_msg);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/// levels of recursion
|
||||
int depth = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue