simplifed api, at expense of parsing naked values (which are an abomination anyways...)
This commit is contained in:
parent
972b4c8ebf
commit
5975048ee4
1 changed files with 39 additions and 217 deletions
|
@ -63,12 +63,7 @@ start(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> start(Resume, Stack, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> start(Resume, Stack, Opts) end);
|
||||||
start(Bin, Stack, Opts) ->
|
start(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> start(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> start(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -87,15 +82,10 @@ maybe_done(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts))
|
||||||
maybe_done(Rest, [], ?multi_term(Opts)) ->
|
maybe_done(Rest, [], ?multi_term(Opts)) ->
|
||||||
{event, end_json, fun() -> start(Rest, [], Opts) end};
|
{event, end_json, fun() -> start(Rest, [], Opts) end};
|
||||||
maybe_done(Rest, [], Opts) ->
|
maybe_done(Rest, [], Opts) ->
|
||||||
{event, end_json, fun() -> done(Rest, Opts) end};
|
done(Rest, Opts);
|
||||||
maybe_done(Bin, Stack, Opts) ->
|
maybe_done(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> maybe_done(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> case Bin == <<>> of true -> ok; false -> {error, badjson} end
|
|
||||||
; (Stream) -> maybe_done(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -103,14 +93,11 @@ done(<<S/?encoding, Rest/binary>>, Opts) when ?is_whitespace(S) ->
|
||||||
done(Rest, Opts);
|
done(Rest, Opts);
|
||||||
done(<<?solidus/?encoding, Rest/binary>>, ?comments_enabled(Opts)) ->
|
done(<<?solidus/?encoding, Rest/binary>>, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> done(Resume, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> done(Resume, Opts) end);
|
||||||
|
done(<<>>, Opts) ->
|
||||||
|
{event, end_json, fun() -> {incomplete, fun(Stream) -> done(Stream, Opts) end} end};
|
||||||
done(Bin, Opts) ->
|
done(Bin, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> done(<<Bin/binary, Stream/binary>>, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> case Bin == <<>> of true -> ok; false -> {error, badjson} end
|
|
||||||
; (Stream) -> done(<<Bin/binary, Stream/binary>>, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -125,12 +112,7 @@ object(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> object(Resume, Stack, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> object(Resume, Stack, Opts) end);
|
||||||
object(Bin, Stack, Opts) ->
|
object(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> object(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> object(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -161,12 +143,7 @@ array(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> array(Resume, Stack, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> array(Resume, Stack, Opts) end);
|
||||||
array(Bin, Stack, Opts) ->
|
array(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> array(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> array(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -195,12 +172,7 @@ value(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> value(Resume, Stack, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> value(Resume, Stack, Opts) end);
|
||||||
value(Bin, Stack, Opts) ->
|
value(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> value(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> value(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -213,12 +185,7 @@ colon(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> colon(Resume, Stack, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> colon(Resume, Stack, Opts) end);
|
||||||
colon(Bin, Stack, Opts) ->
|
colon(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> colon(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> colon(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -231,12 +198,7 @@ key(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts)) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> key(Resume, Stack, Opts) end);
|
maybe_comment(Rest, fun(Resume) -> key(Resume, Stack, Opts) end);
|
||||||
key(Bin, Stack, Opts) ->
|
key(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> key(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> key(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -257,12 +219,7 @@ string(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when ?is_noncontrol(S) ->
|
||||||
string(Rest, Stack, Opts, [S] ++ Acc);
|
string(Rest, Stack, Opts, [S] ++ Acc);
|
||||||
string(Bin, Stack, Opts, Acc) ->
|
string(Bin, Stack, Opts, Acc) ->
|
||||||
case partial_utf(Bin) of
|
case partial_utf(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> string(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> string(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -335,12 +292,7 @@ escape(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc)
|
||||||
string(Rest, Stack, Opts, [S] ++ Acc);
|
string(Rest, Stack, Opts, [S] ++ Acc);
|
||||||
escape(Bin, Stack, Opts, Acc) ->
|
escape(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> escape(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> escape(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -389,12 +341,7 @@ escaped_unicode(<<S/?encoding, Rest/binary>>, Stack, Opts, String, Acc) when ?is
|
||||||
escaped_unicode(Rest, Stack, Opts, String, [S] ++ Acc);
|
escaped_unicode(Rest, Stack, Opts, String, [S] ++ Acc);
|
||||||
escaped_unicode(Bin, Stack, Opts, String, Acc) ->
|
escaped_unicode(Bin, Stack, Opts, String, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> escaped_unicode(<<Bin/binary, Stream/binary>>, Stack, Opts, String, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> escaped_unicode(<<Bin/binary, Stream/binary>>, Stack, Opts, String, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -424,12 +371,7 @@ negative(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when ?is_nonzero(S) ->
|
||||||
integer(Rest, Stack, Opts, [S] ++ Acc);
|
integer(Rest, Stack, Opts, [S] ++ Acc);
|
||||||
negative(Bin, Stack, Opts, Acc) ->
|
negative(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> negative(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> negative(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -453,20 +395,10 @@ zero(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when ?is_whitespace(S) ->
|
||||||
zero(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
zero(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> zero(Resume, Stack, Opts, Acc) end);
|
maybe_comment(Rest, fun(Resume) -> zero(Resume, Stack, Opts, Acc) end);
|
||||||
zero(<<>>, [], Opts, Acc) ->
|
zero(<<>>, [], Opts, Acc) ->
|
||||||
{incomplete,
|
{event, {integer, lists:reverse(Acc)}, fun() -> {incomplete, fun(Stream) -> zero(Stream, [], Opts, Acc) end} end};
|
||||||
fun
|
|
||||||
(end_stream) -> {event, {integer, lists:reverse(Acc)}, fun() -> maybe_done(<<>>, [], Opts) end}
|
|
||||||
; (Stream) -> zero(Stream, [], Opts, Acc)
|
|
||||||
end
|
|
||||||
};
|
|
||||||
zero(Bin, Stack, Opts, Acc) ->
|
zero(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> zero(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> zero(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -498,20 +430,10 @@ integer(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when ?is_whitespace(S) -
|
||||||
integer(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
integer(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> integer(Resume, Stack, Opts, Acc) end);
|
maybe_comment(Rest, fun(Resume) -> integer(Resume, Stack, Opts, Acc) end);
|
||||||
integer(<<>>, [], Opts, Acc) ->
|
integer(<<>>, [], Opts, Acc) ->
|
||||||
{incomplete,
|
{event, {integer, lists:reverse(Acc)}, fun() -> {incomplete, fun(Stream) -> integer(Stream, [], Opts, Acc) end} end};
|
||||||
fun
|
|
||||||
(end_stream) -> {event, {integer, lists:reverse(Acc)}, fun() -> maybe_done(<<>>, [], Opts) end}
|
|
||||||
; (Stream) -> integer(Stream, [], Opts, Acc)
|
|
||||||
end
|
|
||||||
};
|
|
||||||
integer(Bin, Stack, Opts, Acc) ->
|
integer(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> integer(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> integer(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -522,12 +444,7 @@ initial_decimal(<<?zero/?encoding, Rest/binary>>, Stack, Opts, Acc) ->
|
||||||
decimal(Rest, Stack, Opts, [?zero] ++ Acc);
|
decimal(Rest, Stack, Opts, [?zero] ++ Acc);
|
||||||
initial_decimal(Bin, Stack, Opts, Acc) ->
|
initial_decimal(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> initial_decimal(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> initial_decimal(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -557,20 +474,10 @@ decimal(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when ?is_whitespace(S) -
|
||||||
decimal(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
decimal(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> decimal(Resume, Stack, Opts, Acc) end);
|
maybe_comment(Rest, fun(Resume) -> decimal(Resume, Stack, Opts, Acc) end);
|
||||||
decimal(<<>>, [], Opts, Acc) ->
|
decimal(<<>>, [], Opts, Acc) ->
|
||||||
{incomplete,
|
{event, {float, lists:reverse(Acc)}, fun() -> {incomplete, fun(Stream) -> decimal(Stream, [], Opts, Acc) end} end};
|
||||||
fun
|
|
||||||
(end_stream) -> {event, {float, lists:reverse(Acc)}, fun() -> maybe_done(<<>>, [], Opts) end}
|
|
||||||
; (Stream) -> decimal(Stream, [], Opts, Acc)
|
|
||||||
end
|
|
||||||
};
|
|
||||||
decimal(Bin, Stack, Opts, Acc) ->
|
decimal(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> decimal(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> decimal(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -581,12 +488,7 @@ e(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when S =:= ?positive; S =:= ?n
|
||||||
ex(Rest, Stack, Opts, [S] ++ Acc);
|
ex(Rest, Stack, Opts, [S] ++ Acc);
|
||||||
e(Bin, Stack, Opts, Acc) ->
|
e(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> e(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> e(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -595,12 +497,7 @@ ex(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when S =:= ?zero; ?is_nonzero
|
||||||
exp(Rest, Stack, Opts, [S] ++ Acc);
|
exp(Rest, Stack, Opts, [S] ++ Acc);
|
||||||
ex(Bin, Stack, Opts, Acc) ->
|
ex(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> ex(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> ex(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -626,20 +523,10 @@ exp(<<S/?encoding, Rest/binary>>, Stack, Opts, Acc) when ?is_whitespace(S) ->
|
||||||
exp(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
exp(<<?solidus/?encoding, Rest/binary>>, Stack, ?comments_enabled(Opts), Acc) ->
|
||||||
maybe_comment(Rest, fun(Resume) -> exp(Resume, Stack, Opts, Acc) end);
|
maybe_comment(Rest, fun(Resume) -> exp(Resume, Stack, Opts, Acc) end);
|
||||||
exp(<<>>, [], Opts, Acc) ->
|
exp(<<>>, [], Opts, Acc) ->
|
||||||
{incomplete,
|
{event, {float, lists:reverse(Acc)}, fun() -> {incomplete, fun(Stream) -> exp(Stream, [], Opts, Acc) end} end};
|
||||||
fun
|
|
||||||
(end_stream) -> {event, {float, lists:reverse(Acc)}, fun() -> maybe_done(<<>>, [], Opts) end}
|
|
||||||
; (Stream) -> exp(Stream, [], Opts, Acc)
|
|
||||||
end
|
|
||||||
};
|
|
||||||
exp(Bin, Stack, Opts, Acc) ->
|
exp(Bin, Stack, Opts, Acc) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> exp(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> exp(<<Bin/binary, Stream/binary>>, Stack, Opts, Acc)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -648,12 +535,7 @@ tr(<<$r/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
tru(Rest, Stack, Opts);
|
tru(Rest, Stack, Opts);
|
||||||
tr(Bin, Stack, Opts) ->
|
tr(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> tr(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> tr(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -662,12 +544,7 @@ tru(<<$u/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
true(Rest, Stack, Opts);
|
true(Rest, Stack, Opts);
|
||||||
tru(Bin, Stack, Opts) ->
|
tru(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> tru(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> tru(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -676,12 +553,7 @@ true(<<$e/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
{event, {literal, true}, fun() -> maybe_done(Rest, Stack, Opts) end};
|
{event, {literal, true}, fun() -> maybe_done(Rest, Stack, Opts) end};
|
||||||
true(Bin, Stack, Opts) ->
|
true(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> true(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> true(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -690,12 +562,7 @@ fa(<<$a/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
fal(Rest, Stack, Opts);
|
fal(Rest, Stack, Opts);
|
||||||
fa(Bin, Stack, Opts) ->
|
fa(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> fa(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> fa(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -704,12 +571,7 @@ fal(<<$l/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
fals(Rest, Stack, Opts);
|
fals(Rest, Stack, Opts);
|
||||||
fal(Bin, Stack, Opts) ->
|
fal(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> fal(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> fal(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -718,12 +580,7 @@ fals(<<$s/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
false(Rest, Stack, Opts);
|
false(Rest, Stack, Opts);
|
||||||
fals(Bin, Stack, Opts) ->
|
fals(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> fals(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> fals(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -732,12 +589,7 @@ false(<<$e/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
{event, {literal, false}, fun() -> maybe_done(Rest, Stack, Opts) end};
|
{event, {literal, false}, fun() -> maybe_done(Rest, Stack, Opts) end};
|
||||||
false(Bin, Stack, Opts) ->
|
false(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> false(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> false(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -746,12 +598,7 @@ nu(<<$u/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
nul(Rest, Stack, Opts);
|
nul(Rest, Stack, Opts);
|
||||||
nu(Bin, Stack, Opts) ->
|
nu(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> nu(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> nu(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -760,12 +607,7 @@ nul(<<$l/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
null(Rest, Stack, Opts);
|
null(Rest, Stack, Opts);
|
||||||
nul(Bin, Stack, Opts) ->
|
nul(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> nul(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> nul(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -774,12 +616,7 @@ null(<<$l/?encoding, Rest/binary>>, Stack, Opts) ->
|
||||||
{event, {literal, null}, fun() -> maybe_done(Rest, Stack, Opts) end};
|
{event, {literal, null}, fun() -> maybe_done(Rest, Stack, Opts) end};
|
||||||
null(Bin, Stack, Opts) ->
|
null(Bin, Stack, Opts) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> null(<<Bin/binary, Stream/binary>>, Stack, Opts) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> null(<<Bin/binary, Stream/binary>>, Stack, Opts)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -793,12 +630,7 @@ maybe_comment(<<?star/?encoding, Rest/binary>>, Resume) ->
|
||||||
comment(Rest, Resume);
|
comment(Rest, Resume);
|
||||||
maybe_comment(Bin, Resume) ->
|
maybe_comment(Bin, Resume) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> maybe_comment(<<Bin/binary, Stream/binary>>, Resume) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> maybe_comment(<<Bin/binary, Stream/binary>>, Resume)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -809,12 +641,7 @@ comment(<<_/?encoding, Rest/binary>>, Resume) ->
|
||||||
comment(Rest, Resume);
|
comment(Rest, Resume);
|
||||||
comment(Bin, Resume) ->
|
comment(Bin, Resume) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> comment(<<Bin/binary, Stream/binary>>, Resume) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> comment(<<Bin/binary, Stream/binary>>, Resume)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -825,11 +652,6 @@ maybe_comment_done(<<_/?encoding, Rest/binary>>, Resume) ->
|
||||||
comment(Rest, Resume);
|
comment(Rest, Resume);
|
||||||
maybe_comment_done(Bin, Resume) ->
|
maybe_comment_done(Bin, Resume) ->
|
||||||
case ?partial_codepoint(Bin) of
|
case ?partial_codepoint(Bin) of
|
||||||
true ->
|
true -> {incomplete, fun(Stream) -> maybe_comment_done(<<Bin/binary, Stream/binary>>, Resume) end}
|
||||||
{incomplete,
|
|
||||||
fun(end_stream) -> {error, badjson}
|
|
||||||
; (Stream) -> maybe_comment_done(<<Bin/binary, Stream/binary>>, Resume)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
; false -> {error, badjson}
|
; false -> {error, badjson}
|
||||||
end.
|
end.
|
Loading…
Add table
Add a link
Reference in a new issue