Skip to content

Commit

Permalink
preparing to make gml more complex
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcooke committed Jul 18, 2015
1 parent 23fb133 commit bef8c33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/gml/GML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ LISTS = [:graph,:node,:edge]

typealias GMLDict Dict{Symbol, Any}

function build(raw; lists=LISTS, unsafe=false)
function build_dict(raw; lists=LISTS, unsafe=false)
root = GMLDict()
if length(raw) > 0
build(root, raw[1]; lists=lists, unsafe=unsafe)
build_dict(root, raw[1]; lists=lists, unsafe=unsafe)
end
root
end

function build(dict::GMLDict, raw; lists=LISTS, unsafe=false)
function build_dict(dict::GMLDict, raw; lists=LISTS, unsafe=false)
for (name, value) in raw
if isa(value, Vector)
entry = GMLDict()
build(entry, value; lists=lists, unsafe=unsafe)
build_dict(entry, value; lists=lists, unsafe=unsafe)
else
entry = value
end
Expand All @@ -158,6 +158,6 @@ end
# lists describes which symbols should be modelled as lists
# if unsafe is false, multiple values for non-list symbols throw an error;
# if true they are silently discarded
parse_dict(s; debug=false, lists=LISTS, unsafe=false) = build(parse_raw(s; debug=debug); lists=lists, unsafe=unsafe)
parse_dict(s; debug=false, lists=LISTS, unsafe=false) = build_dict(parse_raw(s; debug=debug); lists=lists, unsafe=unsafe)

end
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ importall ParserCombinator
using Base.Test
using Compat

if false

include("core/fix.jl")
include("core/print.jl")
include("core/names.jl")
Expand All @@ -13,7 +13,7 @@ include("core/case.jl")
include("core/calc.jl")
include("core/debug.jl")
include("core/try.jl")
end

include("gml/ok.jl")
include("gml/errors.jl")
include("gml/example1.jl")
Expand Down

0 comments on commit bef8c33

Please sign in to comment.