Skip to content

Commit 8a01917

Browse files
authored
add a TOML standard library to Julia (#37034)
1 parent 5da9691 commit 8a01917

File tree

287 files changed

+8689
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+8689
-2
lines changed

base/sysimg.jl

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ let
4646
:SuiteSparse,
4747
:Distributed,
4848
:SharedArrays,
49+
:TOML,
4950
:Pkg,
5051
:Test,
5152
:REPL,

stdlib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $(build_datarootdir)/julia/stdlib/$(VERSDIR):
1717
STDLIBS = Base64 CRC32c Dates DelimitedFiles Distributed FileWatching \
1818
Future InteractiveUtils Libdl LibGit2 LinearAlgebra Logging \
1919
Markdown Mmap Printf Profile Random REPL Serialization SHA \
20-
SharedArrays Sockets SparseArrays SuiteSparse Test Unicode UUIDs
20+
SharedArrays Sockets SparseArrays SuiteSparse Test TOML Unicode UUIDs
2121
STDLIBS_EXT = Pkg Statistics
2222
PKG_GIT_URL := git://github.com/JuliaLang/Pkg.jl.git
2323
PKG_TAR_URL = https://api.github.com/repos/JuliaLang/Pkg.jl/tarball/$1

stdlib/TOML/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.jl.cov
2+
*.jl.*.cov
3+
*.jl.mem
4+
docs/build
5+
Manifest.toml

stdlib/TOML/LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2016-2020 Art Wild, Julia Computing, Inc., Kristoffer Carlsson and
4+
contributors.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

stdlib/TOML/Project.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name = "TOML"
2+
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
3+
version = "0.1.0"
4+
5+
[deps]
6+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
7+
8+
[extras]
9+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10+
11+
[targets]
12+
test = ["Test"]

stdlib/TOML/benchmark/Manifest.toml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# This file is machine-generated - editing it directly is not advised
2+
3+
[[AbstractTrees]]
4+
deps = ["Markdown"]
5+
git-tree-sha1 = "33e450545eaf7699da1a6e755f9ea65f14077a45"
6+
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
7+
version = "0.3.3"
8+
9+
[[Base64]]
10+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
11+
12+
[[BenchmarkTools]]
13+
deps = ["JSON", "Logging", "Printf", "Statistics", "UUIDs"]
14+
git-tree-sha1 = "9e62e66db34540a0c919d72172cc2f642ac71260"
15+
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
16+
version = "0.5.0"
17+
18+
[[Dates]]
19+
deps = ["Printf"]
20+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
21+
22+
[[Distributed]]
23+
deps = ["Random", "Serialization", "Sockets"]
24+
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
25+
26+
[[InteractiveUtils]]
27+
deps = ["Markdown"]
28+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
29+
30+
[[JSON]]
31+
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
32+
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
33+
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
34+
version = "0.21.0"
35+
36+
[[LeftChildRightSiblingTrees]]
37+
deps = ["AbstractTrees"]
38+
git-tree-sha1 = "71be1eb5ad19cb4f61fa8c73395c0338fd092ae0"
39+
uuid = "1d6d02ad-be62-4b6b-8a6d-2f90e265016e"
40+
version = "0.1.2"
41+
42+
[[LibGit2]]
43+
deps = ["Printf"]
44+
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
45+
46+
[[Libdl]]
47+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
48+
49+
[[LinearAlgebra]]
50+
deps = ["Libdl"]
51+
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
52+
53+
[[Logging]]
54+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
55+
56+
[[Markdown]]
57+
deps = ["Base64"]
58+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
59+
60+
[[Mmap]]
61+
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
62+
63+
[[Parsers]]
64+
deps = ["Dates", "Test"]
65+
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
66+
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
67+
version = "1.0.10"
68+
69+
[[Pkg]]
70+
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
71+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
72+
73+
[[PkgBenchmark]]
74+
deps = ["BenchmarkTools", "Dates", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Pkg", "Printf", "TerminalLoggers", "UUIDs"]
75+
git-tree-sha1 = "6e2856f677f8dcab289ded9c3ffb018fad38f29c"
76+
uuid = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
77+
version = "0.2.10"
78+
79+
[[Printf]]
80+
deps = ["Unicode"]
81+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
82+
83+
[[ProgressLogging]]
84+
deps = ["Logging", "SHA", "UUIDs"]
85+
git-tree-sha1 = "59398022b661b6fd569f25de6b18fde39843196a"
86+
uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
87+
version = "0.1.3"
88+
89+
[[REPL]]
90+
deps = ["InteractiveUtils", "Markdown", "Sockets"]
91+
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
92+
93+
[[Random]]
94+
deps = ["Serialization"]
95+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
96+
97+
[[SHA]]
98+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
99+
100+
[[Serialization]]
101+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
102+
103+
[[Sockets]]
104+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
105+
106+
[[SparseArrays]]
107+
deps = ["LinearAlgebra", "Random"]
108+
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
109+
110+
[[StableRNGs]]
111+
deps = ["Random", "Test"]
112+
git-tree-sha1 = "705f8782b1d532c6db75e0a986fb848a629f971a"
113+
uuid = "860ef19b-820b-49d6-a774-d7a799459cd3"
114+
version = "0.1.1"
115+
116+
[[Statistics]]
117+
deps = ["LinearAlgebra", "SparseArrays"]
118+
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
119+
120+
[[TOML]]
121+
deps = ["Dates"]
122+
path = ".."
123+
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
124+
version = "0.1.0"
125+
126+
[[TerminalLoggers]]
127+
deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"]
128+
git-tree-sha1 = "cbea752b5eef52a3e1188fb31580c3e4fa0cbc35"
129+
uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
130+
version = "0.1.2"
131+
132+
[[Test]]
133+
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
134+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
135+
136+
[[UUIDs]]
137+
deps = ["Random", "SHA"]
138+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
139+
140+
[[Unicode]]
141+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

stdlib/TOML/benchmark/Project.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
4+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
6+
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

stdlib/TOML/benchmark/benchmarks.jl

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using BenchmarkTools
2+
import TOML
3+
import Random
4+
import StableRNGs
5+
6+
randstring(args...) = Random.randstring(StableRNGs.StableRNG(0), args...)
7+
rand(args...) = Random.rand(StableRNGs.StableRNG(0), args...)
8+
9+
const SUITE = BenchmarkGroup()
10+
11+
12+
##########
13+
# Arrays #
14+
##########
15+
16+
SUITE["arrays"] = BenchmarkGroup()
17+
18+
const homogeneous_array = "foo = [" * join(ones(Int, 10^5), ',') * "]"
19+
SUITE["arrays"]["homogeneous"] = @benchmarkable TOML.parse(homogeneous_array)
20+
21+
const heterogeneous_array = "foo = [1.0," * join(ones(Int, 10^5), ',') * "]"
22+
SUITE["arrays"]["heterogeneous"] = @benchmarkable TOML.parse(heterogeneous_array)
23+
24+
25+
###########
26+
# Strings #
27+
###########
28+
29+
SUITE["strings"] = BenchmarkGroup()
30+
31+
const long_string = "foo = " * repr(randstring(10^6))
32+
SUITE["strings"]["long"] = @benchmarkable TOML.parse(long_string)
33+
34+
const short_strings = "foo = [" * join([repr(randstring(3)) for i in 1:10^4], ',') * "]"
35+
SUITE["strings"]["short"] = @benchmarkable TOML.parse(short_strings)
36+
37+
38+
###########
39+
# Numbers #
40+
###########
41+
42+
SUITE["numbers"] = BenchmarkGroup()
43+
44+
const integer_array = "foo = [" * join(rand(Int, 10^5), ',') * "]"
45+
SUITE["numbers"]["integers"] = @benchmarkable TOML.parse(integer_array)
46+
47+
const float_array = "foo = [" * join(rand(10^5), ',') * "]"
48+
SUITE["numbers"]["floats"] = @benchmarkable TOML.parse(float_array)
49+
50+
51+
###################
52+
# Array of Tables #
53+
###################
54+
55+
SUITE["array of tables"] = BenchmarkGroup()
56+
57+
const many_empty_array_of_tables =
58+
repeat("[[foo]] \n", 10^4)
59+
SUITE["array of tables"]["empty"] = @benchmarkable TOML.parse(many_empty_array_of_tables)
60+
61+
62+
#################
63+
# Registry file #
64+
#################
65+
66+
SUITE["registry"] = BenchmarkGroup()
67+
68+
const registry_toml = read(joinpath(@__DIR__, "files", "Registry.toml"), String)
69+
SUITE["registry"]["Registry.toml"] = @benchmarkable TOML.parse(registry_toml)
70+
71+
const compat_toml = read(joinpath(@__DIR__, "files", "Compat.toml"), String)
72+
SUITE["registry"]["Compat.toml"] = @benchmarkable TOML.parse(compat_toml)
73+
74+
75+
############
76+
# Overhead #
77+
############
78+
79+
SUITE["parse empty"] = @benchmarkable TOML.parse("")

0 commit comments

Comments
 (0)