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
|
##### Parse a valid stream
|
||||||
|
|
||||||
```erlang
|
```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_St2} = yamerl_constr:next_chunk(Stream_St1, <<"He">>),
|
||||||
{continue, Stream_St3} = yamerl_constr:next_chunk(Stream_St2, <<"ll">>),
|
{continue, Stream_St3} = yamerl_constr:next_chunk(Stream_St2, <<"ll">>),
|
||||||
yamerl_constr:last_chunk(Stream_St3, <<"o!">>).
|
yamerl_constr:last_chunk(Stream_St3, <<"o!">>).
|
||||||
@ -104,7 +104,7 @@ Returns:
|
|||||||
##### Parse an invalid stream
|
##### Parse an invalid stream
|
||||||
|
|
||||||
```erlang
|
```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_St2} = yamerl_constr:next_chunk(Stream_St1, <<"'He">>),
|
||||||
{continue, Stream_St3} = yamerl_constr:next_chunk(Stream_St2, <<"ll">>),
|
{continue, Stream_St3} = yamerl_constr:next_chunk(Stream_St2, <<"ll">>),
|
||||||
yamerl_constr:last_chunk(Stream_St3, <<"o!">>) % Unfinished single-quoted scalar.
|
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:
|
* To parse a stream:
|
||||||
```erlang
|
```erlang
|
||||||
% Create a new construction state. The only required argument is an
|
% Create a new construction state. The only required argument is an
|
||||||
% arbitrary term describing the source of the data.
|
% arbitrary term describing the source of the data. Here, we use the
|
||||||
Constr_State = yamerl_constr:new("<stdin>"),
|
% 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
|
% Feed the parser with binary chunks. The developer is responsible for
|
||||||
% reading the chunk from the underlying source.
|
% reading the chunk from the underlying source.
|
||||||
|
Loading…
Reference in New Issue
Block a user