Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
grisumbras committed Sep 30, 2023
1 parent 4b1c42f commit f3ec75f
Showing 1 changed file with 87 additions and 132 deletions.
219 changes: 87 additions & 132 deletions include/boost/json/basic_parser_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ parse_document(const char* p, PrevState st)
goto do_doc3;
case state::com1: case state::com2:
case state::com3: case state::com4:
goto do_doc4;
cs = parse_comment( cs.begin(), st, std::true_type() );
goto after_doc4;
}
}
do_doc1:
Expand Down Expand Up @@ -648,18 +649,8 @@ parse_document(const char* p, PrevState st)
}
else if(opt_.allow_comments && *cs == '/')
{
do_doc4:
if(BOOST_JSON_LIKELY(
st != state::com1 && st != state::com2 &&
st != state::com3 && st != state::com4 ))
{
cs = parse_comment( cs.begin(), no_state(), std::true_type() );
}
else
{
cs = parse_comment( cs.begin(), st, std::true_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::true_type() );
after_doc4:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return sentinel();
goto do_doc3;
Expand Down Expand Up @@ -1808,16 +1799,54 @@ parse_object(const char* p,
{
default: BOOST_JSON_UNREACHABLE();
case state::obj1: goto do_obj1;
case state::obj2: goto do_obj2;
case state::obj3: goto do_obj3;
case state::obj2:
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
goto after_obj2;
}
case state::obj3:
{
state st_c;
std::size_t total;
st_.pop(st_c);
st_.pop(total);
cs = parse_string(cs.begin(), st_c, total, std::true_type(), allow_bad_utf8);
goto after_obj3;
}
case state::obj4: goto do_obj4;
case state::obj5: goto do_obj5;
case state::obj5:
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
goto after_obj5;
}
case state::obj6: goto do_obj6;
case state::obj7: goto do_obj7;
case state::obj7:
{
state st_v;
st_.pop(st_v);
cs = parse_value(cs.begin(), st_v, allow_comments, allow_trailing, allow_bad_utf8);
goto after_obj7;
}
case state::obj8: goto do_obj8;
case state::obj9: goto do_obj9;
case state::obj10: goto do_obj10;
case state::obj11: goto do_obj11;
case state::obj10:
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
goto after_obj10;
}
case state::obj11:
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
goto after_obj11;
}
}
}
else
Expand Down Expand Up @@ -1848,18 +1877,8 @@ parse_object(const char* p,
{
if(allow_comments && *cs == '/')
{
do_obj2:
if( st != state::obj2 )
{
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
}
else
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
after_obj2:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::obj2, size);
goto do_obj1;
Expand All @@ -1876,20 +1895,8 @@ parse_object(const char* p,
= BOOST_CURRENT_LOCATION;
return fail(cs.begin(), error::object_too_large, &loc);
}
do_obj3:
if(BOOST_JSON_LIKELY( st != state::obj3 ))
{
cs = parse_string(cs.begin(), no_state(), 0, std::true_type(), allow_bad_utf8);
}
else
{
state st_c;
std::size_t total;
st_.pop(st_c);
st_.pop(total);
cs = parse_string(cs.begin(), st_c, total, std::true_type(), allow_bad_utf8);
st = no_state();
}
cs = parse_string(cs.begin(), no_state(), 0, std::true_type(), allow_bad_utf8);
after_obj3:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::obj3, size);
do_obj4:
Expand All @@ -1900,18 +1907,8 @@ parse_object(const char* p,
{
if(allow_comments && *cs == '/')
{
do_obj5:
if(BOOST_JSON_LIKELY( st != state::obj5 ))
{
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
}
else
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
after_obj5:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::obj5, size);
goto do_obj4;
Expand All @@ -1925,18 +1922,8 @@ parse_object(const char* p,
cs = detail::count_whitespace(cs.begin(), cs.end());
if(BOOST_JSON_UNLIKELY(! cs))
return maybe_suspend(cs.begin(), state::obj6, size);
do_obj7:
if(BOOST_JSON_LIKELY( st != state::obj7 ))
{
cs = parse_value(cs.begin(), no_state(), allow_comments, allow_trailing, allow_bad_utf8);
}
else
{
state st_v;
st_.pop(st_v);
cs = parse_value(cs.begin(), st_v, allow_comments, allow_trailing, allow_bad_utf8);
st = no_state();
}
cs = parse_value(cs.begin(), no_state(), allow_comments, allow_trailing, allow_bad_utf8);
after_obj7:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::obj7, size);
do_obj8:
Expand All @@ -1958,18 +1945,8 @@ parse_object(const char* p,
{
if(allow_comments && *cs == '/')
{
do_obj10:
if(BOOST_JSON_LIKELY( st != state::obj10 ))
{
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
}
else
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
after_obj10:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::obj10, size);
goto do_obj9;
Expand All @@ -1983,18 +1960,8 @@ parse_object(const char* p,
{
if(allow_comments && *cs == '/')
{
do_obj11:
if(BOOST_JSON_LIKELY( st != state::obj11 ))
{
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
}
else
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
after_obj11:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::obj11, size);
goto do_obj8;
Expand Down Expand Up @@ -2038,11 +2005,29 @@ parse_array(
{
default: BOOST_JSON_UNREACHABLE();
case state::arr1: goto do_arr1;
case state::arr2: goto do_arr2;
case state::arr3: goto do_arr3;
case state::arr2:
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
goto after_arr2;
}
case state::arr3:
{
state st_v;
st_.pop(st_v);
cs = parse_value(cs.begin(), st_v, allow_comments, allow_trailing, allow_bad_utf8);
goto after_arr3;
}
case state::arr4: goto do_arr4;
case state::arr5: goto do_arr5;
case state::arr6: goto do_arr6;
case state::arr6:
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
goto after_arr6;
}
}
}
else
Expand Down Expand Up @@ -2072,18 +2057,8 @@ parse_array(
loop:
if(allow_comments && *cs == '/')
{
do_arr2:
if(BOOST_JSON_LIKELY( st != state::arr2 ))
{
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
}
else
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
after_arr2:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::arr2, size);
goto do_arr1;
Expand All @@ -2095,19 +2070,9 @@ parse_array(
= BOOST_CURRENT_LOCATION;
return fail(cs.begin(), error::array_too_large, &loc);
}
do_arr3:
// array is not empty, value required
if(BOOST_JSON_LIKELY( st != state::arr3 ))
{
cs = parse_value(cs.begin(), no_state(), allow_comments, allow_trailing, allow_bad_utf8);
}
else
{
state st_v;
st_.pop(st_v);
cs = parse_value(cs.begin(), st_v, allow_comments, allow_trailing, allow_bad_utf8);
st = no_state();
}
cs = parse_value(cs.begin(), no_state(), allow_comments, allow_trailing, allow_bad_utf8);
after_arr3:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::arr3, size);
do_arr4:
Expand All @@ -2129,18 +2094,8 @@ parse_array(
{
if(allow_comments && *cs == '/')
{
do_arr6:
if(BOOST_JSON_LIKELY( st != state::arr6 ))
{
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
}
else
{
state st_c;
st_.pop(st_c);
cs = parse_comment( cs.begin(), st_c, std::false_type() );
st = no_state();
}
cs = parse_comment( cs.begin(), no_state(), std::false_type() );
after_arr6:
if(BOOST_JSON_UNLIKELY(incomplete(cs)))
return suspend_or_fail(state::arr6, size);
goto do_arr4;
Expand Down

0 comments on commit f3ec75f

Please sign in to comment.