mirror of
https://github.com/valitydev/yamerl.git
synced 2024-11-06 02:45:23 +00:00
Use yamerl_constr:new({file, ...}), like yamerl_constr:file/{1, 2}
This commit is contained in:
parent
7d38065b3c
commit
511f7928e6
@ -86,7 +86,7 @@ If parsing or construction fails, throw an exception.
|
||||
##### Parse a valid stream
|
||||
|
||||
```erlang
|
||||
Stream_St1 = yamerl_constr:new("<stdin>"),
|
||||
Stream_St1 = yamerl_constr:new({file, "<stdin>"}),
|
||||
{continue, Stream_St2} = yamerl_constr:next_chunk(Stream_St1, <<"He">>),
|
||||
{continue, Stream_St3} = yamerl_constr:next_chunk(Stream_St2, <<"ll">>),
|
||||
yamerl_constr:last_chunk(Stream_St3, <<"o!">>).
|
||||
@ -104,7 +104,7 @@ Returns:
|
||||
##### Parse an invalid stream
|
||||
|
||||
```erlang
|
||||
Stream_St1 = yamerl_constr:new("<stdin>"),
|
||||
Stream_St1 = yamerl_constr:new({file, "<stdin>"}),
|
||||
{continue, Stream_St2} = yamerl_constr:next_chunk(Stream_St1, <<"'He">>),
|
||||
{continue, Stream_St3} = yamerl_constr:next_chunk(Stream_St2, <<"ll">>),
|
||||
yamerl_constr:last_chunk(Stream_St3, <<"o!">>) % Unfinished single-quoted scalar.
|
||||
|
@ -18,8 +18,9 @@ Documents = yamerl_constr:file("input.yaml").
|
||||
* To parse a stream:
|
||||
```erlang
|
||||
% Create a new construction state. The only required argument is an
|
||||
% arbitrary term describing the source of the data.
|
||||
Constr_State = yamerl_constr:new("<stdin>"),
|
||||
% arbitrary term describing the source of the data. Here, we use the
|
||||
% same term structure as yamerl_constr:file/{1, 2}.
|
||||
Constr_State = yamerl_constr:new({file, "<stdin>"}),
|
||||
|
||||
% Feed the parser with binary chunks. The developer is responsible for
|
||||
% reading the chunk from the underlying source.
|
||||
|
Loading…
Reference in New Issue
Block a user