Skip to content

Commit

Permalink
Merge pull request #38 from KristofferC/kc/fixtoml
Browse files Browse the repository at this point in the history
bump TOML
  • Loading branch information
KristofferC authored Nov 26, 2017
2 parents b0c714b + 173803f commit 490e914
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ext/TOML/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:
- linux
- osx
julia:
# - release
- 0.6
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion ext/TOML/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ julia> using TOML
julia> TOML.parse("""
name = "value"
""")
Dict{AbstractString,Any} with 1 entry:
Dict{String,Any} with 1 entry:
"name" => "value"

julia> TOML.parsefile("etc/example.toml")
Expand Down
2 changes: 1 addition & 1 deletion ext/TOML/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
julia 0.5-
julia 0.6
10 changes: 5 additions & 5 deletions ext/TOML/appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
environment:
matrix:
# - JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
# - JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

branches:
only:
Expand All @@ -18,7 +18,7 @@ notifications:
install:
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$("http://s3.amazonaws.com/"+$env:JULIAVERSION),
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
Expand Down
10 changes: 3 additions & 7 deletions ext/TOML/src/TOML.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
module TOML

if VERSION < v"0.6-"
eachline(args...; chomp=false) = (@assert !chomp; Base.eachline(args...))
end

include("parser.jl")
include("print.jl")

"Convert `TOML.Table` to `Dict{AbstractString,Any}`"
"Convert `TOML.Table` to `Dict{String,Any}`"
function table2dict(tbl::Nullable{Table})
isnull(tbl) && return Dict{AbstractString,Any}()
isnull(tbl) && return Dict{String,Any}()
return table2dict(get(tbl))
end

function table2dict(tbl::Table)
ret = Dict{AbstractString,Any}()
ret = Dict{String,Any}()
for (k,v) in tbl.values
if isa(v, Table)
ret[k] = table2dict(v)
Expand Down
18 changes: 9 additions & 9 deletions ext/TOML/src/parser.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
NONE() = Nullable()
NONE{T}(::Type{T}) = Nullable{T}()
SOME{T}(v::T) = Nullable{T}(v)
NONE(::Type{T}) where {T} = Nullable{T}()
SOME(v::T) where {T} = Nullable{T}(v)

"TOML Table"
type Table
values::Dict{AbstractString,Any}
mutable struct Table
values::Dict{String,Any}
defined::Bool
end

Table(defined::Bool) = Table(Dict{AbstractString,Any}(), defined)
Table(defined::Bool) = Table(Dict{String,Any}(), defined)
function Base.show(io::IO, tbl::Table, level::Int=1)
Base.print(io, "T($(tbl.defined)){\n")
for (k,v) in tbl.values
Expand All @@ -34,14 +34,14 @@ Base.getindex(tbl::Table, key::AbstractString) = tbl.values[key]
Base.haskey(tbl::Table, key::AbstractString) = haskey(tbl.values ,key)

"Parser error exception"
type ParserError <: Exception
mutable struct ParserError <: Exception
lo::Int
hi::Int
msg::String
end

"TOML Parser"
type Parser
mutable struct Parser
input::IO
errors::Vector{ParserError}

Expand All @@ -50,15 +50,15 @@ end
Parser(input::String) = Parser(IOBuffer(input))
Base.error(p::Parser, l, h, msg) = push!(p.errors, ParserError(l, h, msg))
Base.eof(p::Parser) = eof(p.input)
Base.position(p::Parser) = position(p.input)+1
Base.position(p::Parser) = Int(position(p.input))+1
Base.read(p::Parser) = read(p.input, Char)

"Rewind parser input on `n` characters."
function rewind(p::Parser, n=1)
pos = position(p.input)
pos == 0 && return 0
skip(p.input, -n)
return position(p.input)
return Int(position(p.input))
end

"Converts an offset to a line and a column in the original source."
Expand Down
2 changes: 1 addition & 1 deletion ext/TOML/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ trimmed in raw strings.
a = [2]
[[a]]
b = 5
", "expected type `TOML.Table`, found type `Int64`")
", "expected type `TOML.Table`, found type `$(Int)`")
@fail("
a = 1
[a.b]
Expand Down

0 comments on commit 490e914

Please sign in to comment.