Skip to content

Commit 06b5aed

Browse files
authored
Expose resolver to load (#197)
* Add type assertions for function arguments in `src/composer.jl`. * Add missing type annotations. * Expose resolver to the function `load`. This is required to inform a resolver when loading by users.
1 parent 41ac452 commit 06b5aed

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/YAML.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ function _patch_constructors(more_constructors::_constructor, dicttype::_dicttyp
5757
return more_constructors
5858
end
5959

60-
6160
"""
6261
load(x::Union{AbstractString, IO})
6362
6463
Parse the string or stream `x` as a YAML file, and return the first YAML document as a
6564
Julia object.
6665
"""
67-
load(ts::TokenStream, constructor::Constructor) =
68-
construct_document(constructor, compose(EventStream(ts)))
66+
function load(tokenstream::TokenStream, constructor::Constructor)
67+
resolver = Resolver()
68+
eventstream = EventStream(tokenstream)
69+
node = compose(eventstream, resolver)
70+
construct_document(constructor, node)
71+
end
6972

7073
load(input::IO, constructor::Constructor) =
7174
load(TokenStream(input), constructor)

src/composer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ mutable struct Composer
2727
resolver::Resolver
2828
end
2929

30-
function compose(events::EventStream)
31-
composer = Composer(events, Dict{String, Node}(), Resolver())
30+
function compose(events::EventStream, resolver::Resolver)
31+
composer = Composer(events, Dict{String, Node}(), resolver)
3232
@assert forward!(composer.input) isa StreamStartEvent
3333
node = compose_document(composer)
3434
if peek(composer.input) isa StreamEndEvent

0 commit comments

Comments
 (0)