diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 961fa21..eda320f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,9 @@ jobs: arch: - x64 - x86 + exclude: + - os: macOS-latest + arch: x86 steps: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 @@ -44,13 +47,3 @@ jobs: - uses: codecov/codecov-action@v1 with: file: lcov.info - docs: - name: Documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/julia-buildpkg@latest - - uses: julia-actions/julia-docdeploy@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/README.md b/README.md index 412c446..3247636 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ [![Build status](https://github.com/andrewcooke/ParserCombinator.jl/workflows/CI/badge.svg)](https://github.com/andrewcooke/ParserCombinator.jl/actions?query=workflow%3ACI+branch%3Amaster) [![Codecov](https://codecov.io/gh/andrewcooke/ParserCombinator.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/andrewcooke/ParserCombinator.jl) -[![ParserCombinator](http://pkg.julialang.org/badges/ParserCombinator_0.3.svg)](http://pkg.julialang.org/?pkg=ParserCombinator&ver=0.3) -[![ParserCombinator](http://pkg.julialang.org/badges/ParserCombinator_0.4.svg)](http://pkg.julialang.org/?pkg=ParserCombinator&ver=0.4) -[![ParserCombinator](http://pkg.julialang.org/badges/ParserCombinator_0.5.svg)](http://pkg.julialang.org/?pkg=ParserCombinator&ver=0.5) - # ParserCombinator diff --git a/src/core/debug.jl b/src/core/debug.jl index c1b4787..ba52ed8 100644 --- a/src/core/debug.jl +++ b/src/core/debug.jl @@ -71,13 +71,7 @@ MAX_RES = 50 MAX_SRC = 10 MAX_IND = 10 -if VERSION < v"0.4-" - shorten(s) = s -else -# shorten(s) = replace(s, r"(?:[a-zA-Z]+\.)+([a-zA-Z]+)", s"\1") - shorten(s) = replace(s, r"(?:[a-zA-Z]+\.)+([a-zA-Z]+)" => - Base.SubstitutionString("\1")) -end +shorten(s) = replace(s, r"(?:[a-zA-Z]+\.)+([a-zA-Z]+)" => s"\1") function truncate(s::AbstractString, n=10) if length(s) <= n @@ -135,7 +129,7 @@ function src(s::LineAt, i::LineIter; max=MAX_SRC) end end end - + function debug(k::Debug{S}, e::Execute) where {S<:LineAt} @printf("%3d,%-3d:%s %02d %s%s->%s\n", e.iter.line, e.iter.column, src(k.source, e.iter), k.depth[end], indent(k), e.parent.name, e.child.name) diff --git a/src/core/parsers.jl b/src/core/parsers.jl index 457d57e..24b419e 100644 --- a/src/core/parsers.jl +++ b/src/core/parsers.jl @@ -149,7 +149,7 @@ function producer(c::Channel, k::Config, m::Matcher; debug=false) end end end - + catch x if (debug) println("debug was set, so showing error from inside task") @@ -165,7 +165,7 @@ end # helper functions to generate the parsers from the above -# these assume that any config construct takes a single source argument +# these assume that any config construct takes a single source argument # plus optional keyword args function make(config, source::S, matcher; debug=false, kargs...) where {S} @@ -181,8 +181,17 @@ function make_all(config; kargs_make...) end function once(channel) - for result in channel - return result + try + for result in channel + return result + end + catch ex + # unwrap exception + if VERSION >= v"1.1" + ex isa TaskFailedException ? throw(first(first(Base.catch_stack(ex.task)))) : rethrow() + else + rethrow() + end end throw(ParserException("cannot parse")) end diff --git a/test/REQUIRE b/test/REQUIRE deleted file mode 100644 index e69de29..0000000 diff --git a/test/core/calc.jl b/test/core/calc.jl index 2576348..3aaacc4 100644 --- a/test/core/calc.jl +++ b/test/core/calc.jl @@ -54,7 +54,6 @@ for (src, val) in [ ] # @test_approx_eq calc(parse_dbg(src, Trace(all))[1]) val @test calc(parse_one(src, Trace(all))[1]) ≈ val - println("$src = $val") end for (src, ast, val) in @@ -168,6 +167,4 @@ for i in 1:20 end end -println("calc ok") - end diff --git a/test/core/case.jl b/test/core/case.jl index b8c7c2d..9a6d500 100644 --- a/test/core/case.jl +++ b/test/core/case.jl @@ -55,6 +55,4 @@ end # and we can see that Case calls Pattern, as expected; that the Pattern # returns foo; and that Case transforms that to Foo. -println("case ok") - end diff --git a/test/core/debug.jl b/test/core/debug.jl index 793490e..ae49121 100644 --- a/test/core/debug.jl +++ b/test/core/debug.jl @@ -22,6 +22,4 @@ debug, task = make(Debug, "123abc", grammar; delegate=NoCache) @test_throws ParserException once(task) @test debug.max_iter == 4 -println("debug ok") - end diff --git a/test/core/fix.jl b/test/core/fix.jl index a2c3436..aaa9c90 100644 --- a/test/core/fix.jl +++ b/test/core/fix.jl @@ -57,10 +57,6 @@ for (src, v) in [ ] # @test calc(parse_dbg(src, Trace(all))[1]) ≈ v @test calc(parse_one(src, Trace(all))[1]) ≈ v - println("$src = $v") end - -println("fix ok") - end diff --git a/test/core/names.jl b/test/core/names.jl index 7dd1890..66f1b0a 100644 --- a/test/core/names.jl +++ b/test/core/names.jl @@ -8,6 +8,4 @@ end @test a.name == :a @test b.name == :b -println("names ok") - end diff --git a/test/core/print.jl b/test/core/print.jl index 5152589..3dca9ee 100644 --- a/test/core/print.jl +++ b/test/core/print.jl @@ -3,6 +3,4 @@ println(Seq()) println(e"a" + E"b" | p"c" > tuple) -println("print ok") - end diff --git a/test/core/slow.jl b/test/core/slow.jl index 03b9d91..05c7e15 100644 --- a/test/core/slow.jl +++ b/test/core/slow.jl @@ -31,6 +31,4 @@ end slow(3) #slow(7) # not for travis! -println("slow ok") - end diff --git a/test/core/sources.jl b/test/core/sources.jl index 19d3674..eea34ce 100644 --- a/test/core/sources.jl +++ b/test/core/sources.jl @@ -28,6 +28,4 @@ line = Trace(p"(.|\n)+"[0:end] + Eos()) @test parse_one("abc\n", line) == ["abc\n"] @test parse_one(LineSource("abc\n"), line) == ["abc\n"] -println("sources ok") - end diff --git a/test/core/speed.jl b/test/core/speed.jl index d8f36ca..df841a6 100644 --- a/test/core/speed.jl +++ b/test/core/speed.jl @@ -29,8 +29,8 @@ function run_type(n) println("types: $count") end -type A end -type B end +struct A end +struct B end function random_type() if rand(1:2) == 1 diff --git a/test/core/stack.jl b/test/core/stack.jl index 5344df3..cb46d51 100644 --- a/test/core/stack.jl +++ b/test/core/stack.jl @@ -16,18 +16,18 @@ stack(0, 10) @time println(stack(0, 100_000)) # stack limit is somewhere around 100,000 (certainly less than 200,000) -abstract Msg +abstract type Msg end -type Call<:Msg +struct Call <: Msg before::Function after::Function value::Int end -type Return<:Msg +struct Return <: Msg value::Int end - + function inc(n, m) if n > m Return(n) @@ -55,7 +55,7 @@ function trampoline(n, m) end n end - + trampoline(0, 10) @time println(trampoline(0, 100_000)) diff --git a/test/core/tests.jl b/test/core/tests.jl index d1be756..5d54896 100644 --- a/test/core/tests.jl +++ b/test/core/tests.jl @@ -68,7 +68,6 @@ for i in 1:10 n = rand(0:4) s = repeat("a", n) m = match(r, s) - println("$lo $hi $s $r") if m === nothing @test_throws ParserException parse_one(s, Repeat(Equal("a"), lo, hi; greedy=greedy)) else @@ -104,6 +103,4 @@ for backtrack in (true, false) [3,0]] end -println("tests ok") - end diff --git a/test/core/try.jl b/test/core/try.jl index d1751ec..ef6c4e4 100644 --- a/test/core/try.jl +++ b/test/core/try.jl @@ -24,19 +24,14 @@ for parse in (parse_try, parse_try_cache, parse_try_dbg, parse_try_cache_dbg) end open("core/test1.txt", "r") do io result = parse(io, Try(p"[a-z]"[0:end] + e"m" > string)) - println(result) @test result == Any["abcdefghijklm"] end open("core/test1.txt", "r") do io # multiple lines result = parse(io, Try(p"(.|\n)"[0:end] + e"5" > string)) - println(result) @test result == Any["abcdefghijklmnopqrstuvwxyz\n012345"] end @test_throws ParserError{LineIter} parse("?", Alt!(p"[a-z]", p"\d", Error("not letter or number"))) end - -println("try ok") - end diff --git a/test/dot/examples.jl b/test/dot/examples.jl index bb0a241..dcffbb0 100644 --- a/test/dot/examples.jl +++ b/test/dot/examples.jl @@ -80,6 +80,4 @@ d1, d2 = d @test nodes(d2) == Set(["a", "b", "c", "d", "e"]) @test edges(d2) == Set([("a","e"),("c","d"),("c","e"),("b","c"),("a","c"),("a","b")]) -println("examples ok") - end diff --git a/test/dot/fragments.jl b/test/dot/fragments.jl index 04bc81d..272486c 100644 --- a/test/dot/fragments.jl +++ b/test/dot/fragments.jl @@ -40,30 +40,28 @@ str_one = D.str_one > D.unesc_join @test parse_one(":n", D.port)[1] == Port("n") @test parse_one(":A", D.port)[1] == Port(StringID("A")) -@test parse_one("[a=b]", D.attr_list)[1] == +@test parse_one("[a=b]", D.attr_list)[1] == Attribute[Attribute(StringID("a"), StringID("b"))] -@test parse_one("[a=b c = d]", D.attr_list)[1] == -Attribute[Attribute(StringID("a"), StringID("b")), +@test parse_one("[a=b c = d]", D.attr_list)[1] == +Attribute[Attribute(StringID("a"), StringID("b")), Attribute(StringID("c"), StringID("d"))] -@test parse_one("[a=b; c = d]", D.attr_list)[1] == -Attribute[Attribute(StringID("a"), StringID("b")), +@test parse_one("[a=b; c = d]", D.attr_list)[1] == +Attribute[Attribute(StringID("a"), StringID("b")), Attribute(StringID("c"), StringID("d"))] -@test parse_one("[a=b,c=d][e=f]", D.attr_list)[1] == -Attribute[Attribute(StringID("a"), StringID("b")), +@test parse_one("[a=b,c=d][e=f]", D.attr_list)[1] == +Attribute[Attribute(StringID("a"), StringID("b")), Attribute(StringID("c"), StringID("d")), Attribute(StringID("e"), StringID("f"))] -@test parse_one("a:b:c[d=e]", D.node_stmt)[1] == -Node(NodeID(StringID("a"), Port(StringID("b"), "c")), +@test parse_one("a:b:c[d=e]", D.node_stmt)[1] == +Node(NodeID(StringID("a"), Port(StringID("b"), "c")), Attribute[Attribute(StringID("d"), StringID("e"))]) @test parse_one("a--b[c=d]", D.edge_stmt)[1] == -Edge(EdgeNode[NodeID(StringID("a")), NodeID(StringID("b"))], +Edge(EdgeNode[NodeID(StringID("a")), NodeID(StringID("b"))], Attribute[Attribute(StringID("c"), StringID("d"))]) @test parse_one("graph [a=b]", D.attr_stmt)[1] == GraphAttributes(Attribute[Attribute(StringID("a"), StringID("b"))]) -println("fragments ok") - end diff --git a/test/dot/subgraphs.jl b/test/dot/subgraphs.jl index 189cadf..dae742a 100644 --- a/test/dot/subgraphs.jl +++ b/test/dot/subgraphs.jl @@ -44,6 +44,4 @@ graph { @test nodes(d) == Set(["a", "b", "c", "d"]) @test edges(d) == Set([("a","b"),("a","c"),("a","d"),("b","c"),("b","d"),("c","d")]) -println("subgraphs ok") - end diff --git a/test/gml/10k-49963.jl b/test/gml/10k-49963.jl index f50f96b..c4728b2 100644 --- a/test/gml/10k-49963.jl +++ b/test/gml/10k-49963.jl @@ -1,7 +1,6 @@ @testset "10k-49963" begin -println("10k-49963") s = open(s -> read(s, String), "gml/10k-49963.gml") parse_raw(s; debug=false) @time parse_raw(s; debug=false) diff --git a/test/gml/celegansneural.jl b/test/gml/celegansneural.jl index 5105f96..3a7ae22 100644 --- a/test/gml/celegansneural.jl +++ b/test/gml/celegansneural.jl @@ -1,7 +1,6 @@ @testset "celegansneural" begin -println("celegansneural") s = open(s -> read(s, String), "gml/celegansneural.gml") parse_dict(s; debug=false) @time x = parse_dict(s; debug=false) diff --git a/test/gml/errors.jl b/test/gml/errors.jl index 2188d1f..c7f16ec 100644 --- a/test/gml/errors.jl +++ b/test/gml/errors.jl @@ -14,12 +14,7 @@ for (text, msg) in [("a 1 ]", "Expected key"), end end - if VERSION < v"0.5-" - @test_throws ParserError parse_raw(text) - else - @test_throws ParserError{Int64} parse_raw(text) - end - + @test_throws ParserError{Int} parse_raw(text) end diff --git a/test/gml/polblogs.jl b/test/gml/polblogs.jl index 9747da6..c4ac68b 100644 --- a/test/gml/polblogs.jl +++ b/test/gml/polblogs.jl @@ -14,7 +14,6 @@ #io = open("gml/polblogs.gml") #@time parse_id_dict(io; debug=false) -println("polblogs") s = open(s -> read(s, String), "gml/polblogs.gml") x = parse_dict(s; debug=false) @test length(x[:graph][1][:edge]) == 19090