fixed a bug

This commit is contained in:
Niels 2015-02-11 13:15:22 +01:00
parent 032bcf6493
commit 7b7a54aca5
3 changed files with 28 additions and 21 deletions

View File

@ -2476,7 +2476,7 @@ class basic_json
unsigned int yyaccept = 0; unsigned int yyaccept = 0;
static const unsigned char yybm[] = static const unsigned char yybm[] =
{ {
64, 64, 64, 64, 64, 64, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64,
64, 192, 192, 64, 64, 192, 64, 64, 64, 192, 192, 64, 64, 192, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
@ -2650,6 +2650,10 @@ json_parser_7:
json_parser_8: json_parser_8:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 0x00)
{
goto json_parser_6;
}
goto json_parser_53; goto json_parser_53;
json_parser_9: json_parser_9:
++m_cursor; ++m_cursor;
@ -2955,6 +2959,10 @@ json_parser_53:
{ {
goto json_parser_52; goto json_parser_52;
} }
if (yych <= 0x00)
{
goto json_parser_29;
}
if (yych <= '"') if (yych <= '"')
{ {
goto json_parser_55; goto json_parser_55;

View File

@ -2514,7 +2514,7 @@ class basic_json
// string // string
quotation_mark = [\"]; quotation_mark = [\"];
escape = [\\]; escape = [\\];
unescaped = [^\"\\]; unescaped = [^\"\\\000];
escaped = escape ([\"\\/bfnrt] | [u][0-9a-fA-F]{4}); escaped = escape ([\"\\/bfnrt] | [u][0-9a-fA-F]{4});
char = unescaped | escaped; char = unescaped | escaped;
string = quotation_mark char* quotation_mark; string = quotation_mark char* quotation_mark;

View File

@ -4044,7 +4044,7 @@ TEST_CASE("lexer class")
switch (c) switch (c)
{ {
// characters that are prefixes of reasonable json // single characters that are valid tokens
case ('['): case ('['):
case (']'): case (']'):
case ('{'): case ('{'):
@ -4066,12 +4066,6 @@ TEST_CASE("lexer class")
break; break;
} }
case ('"'):
{
// no idea what to do here
break;
}
// whitespace // whitespace
case (' '): case (' '):
case ('\t'): case ('\t'):
@ -4199,32 +4193,37 @@ TEST_CASE("parser class")
SECTION("parse errors") SECTION("parse errors")
{ {
// unexpected end of number // unexpected end of number
CHECK_THROWS_AS(json::parser("0.A").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("0.").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("-,").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("-").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("-A").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("--").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("-0.").parse(), std::invalid_argument);
// unexpected end of null // unexpected end of null
CHECK_THROWS_AS(json::parser("n").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("n").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("nA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("n").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("nuA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("nu").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("nulA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("nul").parse(), std::invalid_argument);
// unexpected end of true // unexpected end of true
CHECK_THROWS_AS(json::parser("t").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("t").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("tA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("t").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("trA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("tr").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("truA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("tru").parse(), std::invalid_argument);
// unexpected end of false // unexpected end of false
CHECK_THROWS_AS(json::parser("f").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("f").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("faA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("fa").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("falA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("fal").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("falsA").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("fals").parse(), std::invalid_argument);
// unexpected end of array // unexpected end of array
CHECK_THROWS_AS(json::parser("[1,").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("[1,]").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("[1,]").parse(), std::invalid_argument);
// unexpected end of object // unexpected end of object
CHECK_THROWS_AS(json::parser("{").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("{\"foo\"").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("{\"foo\":").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("{\"foo\":}").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("{\"foo\":}").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("{\"foo\":1,}").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("{\"foo\":1,}").parse(), std::invalid_argument);
} }