@@ -25,7 +25,7 @@ module Internals
2525end
2626
2727# https://github.com/JuliaLang/julia/issues/36605
28- readstring (f:: AbstractString ) = isfile (f) ? read (f, String) : error (repr (f), " : No such file" )
28+ _readstring (f:: AbstractString ) = isfile (f) ? read (f, String) : error (repr (f), " : No such file" )
2929
3030"""
3131 Parser()
@@ -55,9 +55,9 @@ Parse file `f` and return the resulting table (dictionary). Throw a
5555See also [`TOML.tryparsefile`](@ref).
5656"""
5757parsefile (f:: AbstractString ) =
58- Internals. parse (Internals. Parser {Dates} (readstring (f); filepath= abspath (f)))
58+ Internals. parse (Internals. Parser {Dates} (_readstring (f); filepath= abspath (f)))
5959parsefile (p:: Parser , f:: AbstractString ) =
60- Internals. parse (Internals. reinit! (p. _p, readstring (f); filepath= abspath (f)))
60+ Internals. parse (Internals. reinit! (p. _p, _readstring (f); filepath= abspath (f)))
6161
6262"""
6363 tryparsefile(f::AbstractString)
@@ -69,9 +69,9 @@ Parse file `f` and return the resulting table (dictionary). Return a
6969See also [`TOML.parsefile`](@ref).
7070"""
7171tryparsefile (f:: AbstractString ) =
72- Internals. tryparse (Internals. Parser {Dates} (readstring (f); filepath= abspath (f)))
72+ Internals. tryparse (Internals. Parser {Dates} (_readstring (f); filepath= abspath (f)))
7373tryparsefile (p:: Parser , f:: AbstractString ) =
74- Internals. tryparse (Internals. reinit! (p. _p, readstring (f); filepath= abspath (f)))
74+ Internals. tryparse (Internals. reinit! (p. _p, _readstring (f); filepath= abspath (f)))
7575
7676"""
7777 parse(x::Union{AbstractString, IO})
@@ -135,4 +135,17 @@ supported type.
135135"""
136136const print = Internals. Printer. print
137137
138+ public Parser, parsefile, tryparsefile, parse, tryparse, ParserError, print
139+
140+ # These methods are private Base interfaces, but we do our best to support them over
141+ # the TOML stdlib types anyway to minimize downstream breakage.
142+ Base. TOMLCache (p:: Parser ) = Base. TOMLCache (p. _p, Dict {String, Base.CachedTOMLDict} ())
143+ Base. TOMLCache (p:: Parser , d:: Base.CachedTOMLDict ) = Base. TOMLCache (p. _p, d)
144+ Base. TOMLCache (p:: Parser , d:: Dict{String, Dict{String, Any}} ) = Base. TOMLCache (p. _p, d)
145+
146+ Internals. reinit! (p:: Parser , str:: String ; filepath:: Union{Nothing, String} = nothing ) =
147+ Internals. reinit! (p. _p, str; filepath)
148+ Internals. parse (p:: Parser ) = Internals. parse (p. _p)
149+ Internals. tryparse (p:: Parser ) = Internals. tryparse (p. _p)
150+
138151end
0 commit comments