mirror of
https://github.com/valitydev/yamerl.git
synced 2024-11-06 10:55:16 +00:00
parent
0a47c486f7
commit
510aa11954
@ -8,7 +8,8 @@
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
-type yamerl_parser_token_fun() ::
|
||||
fun((yamerl_token() | term()) -> ok | {ok, yamerl_parser_token_fun()}).
|
||||
fun((yamerl_token() | term()) ->
|
||||
ok | {ok, yamerl_parser_token_fun()} | term()).
|
||||
|
||||
-type yamerl_parser_option() :: {default_tags, [{tag_uri(), tag_prefix()}]}
|
||||
| {document_version, document_version()}
|
||||
|
@ -102,22 +102,24 @@ new(Source, Options) ->
|
||||
next_chunk(Parser, Chunk) ->
|
||||
next_chunk(Parser, Chunk, false).
|
||||
|
||||
-spec next_chunk(Parser, Chunk, Last_Chunk) ->
|
||||
-spec next_chunk(Parser, Chunk, false) ->
|
||||
Ret | no_return() when
|
||||
Parser :: yamerl_parser:yamerl_parser(),
|
||||
Chunk :: unicode_binary(),
|
||||
Last_Chunk :: boolean(),
|
||||
Ret :: {continue, New_Parser} | Result,
|
||||
New_Parser :: yamerl_parser:yamerl_parser(),
|
||||
Ret :: {continue, New_Parser},
|
||||
New_Parser :: yamerl_parser:yamerl_parser();
|
||||
(Parser, Chunk, true) ->
|
||||
Result | no_return() when
|
||||
Parser :: yamerl_parser:yamerl_parser(),
|
||||
Chunk :: unicode_binary(),
|
||||
Result :: [yamerl_doc()]
|
||||
| [yamerl_simple_doc()]
|
||||
| term().
|
||||
| [yamerl_simple_doc()].
|
||||
|
||||
next_chunk(Parser, Chunk, EOS) ->
|
||||
Parser = yamerl_parser:next_chunk(Parser, Chunk, EOS),
|
||||
Ret = yamerl_parser:next_chunk(Parser, Chunk, EOS),
|
||||
if
|
||||
EOS -> get_docs(Parser);
|
||||
true -> Parser
|
||||
EOS -> get_docs(Ret);
|
||||
true -> Ret
|
||||
end.
|
||||
|
||||
-spec last_chunk(Parser, Chunk) ->
|
||||
@ -125,12 +127,17 @@ next_chunk(Parser, Chunk, EOS) ->
|
||||
Parser :: yamerl_parser:yamerl_parser(),
|
||||
Chunk :: unicode_binary(),
|
||||
Result :: [yamerl_doc()]
|
||||
| [yamerl_simple_doc()]
|
||||
| term().
|
||||
| [yamerl_simple_doc()].
|
||||
|
||||
last_chunk(Parser, Chunk) ->
|
||||
next_chunk(Parser, Chunk, true).
|
||||
|
||||
-spec get_docs(Parser) ->
|
||||
Docs | no_return() when
|
||||
Parser :: yamerl_parser:yamerl_parser(),
|
||||
Docs :: [yamerl_doc()]
|
||||
| [yamerl_simple_doc()].
|
||||
|
||||
get_docs(Parser) ->
|
||||
case yamerl_parser:get_token_fun(Parser) of
|
||||
Not_Fun when Not_Fun == acc orelse Not_Fun == drop ->
|
||||
|
Loading…
Reference in New Issue
Block a user