diff --git a/README.md b/README.md index 4058013..ce0ee93 100644 --- a/README.md +++ b/README.md @@ -457,7 +457,7 @@ The action of `Appl()` and `|>` is similar, but everything is passed as a single argument (a list). ```julia -julia> type Node children end +julia> mutable struct Node children end julia> parse_one("abc", Appl(Star(p"."), Node)) 1-element Array{Any,1}: diff --git a/src/core/debug.jl b/src/core/debug.jl index 4fbf0ff..9fdb0e6 100644 --- a/src/core/debug.jl +++ b/src/core/debug.jl @@ -153,7 +153,7 @@ end # this does nothing except delegate and, by simply "being seen" during # disparch above, toggle debug state. -@auto_hash_equals type Trace<:Delegate +@auto_hash_equals mutable struct Trace<:Delegate name::Symbol matcher::Matcher Trace(matcher) = new(:Trace, matcher) diff --git a/src/core/matchers.jl b/src/core/matchers.jl index 24fd186..718c092 100644 --- a/src/core/matchers.jl +++ b/src/core/matchers.jl @@ -314,7 +314,7 @@ end # when first called, create base state and make internal transition -execute{S,I}(k::Config{S,I}, m::Breadth, s::Clean, i::I) = execute(k, m, BreadthYield{I}(i, Entry{I}[Entry{I}(i, CLEAN, Any[])]), i) +execute(k::Config{S,I}, m::Breadth, s::Clean, i::I) where {S,I} = execute(k, m, BreadthYield{I}(i, Entry{I}[Entry{I}(i, CLEAN, Any[])]), i) # yield the top state diff --git a/src/core/parsers.jl b/src/core/parsers.jl index d2ac6ca..2548496 100644 --- a/src/core/parsers.jl +++ b/src/core/parsers.jl @@ -165,7 +165,7 @@ end # these assume that any config construct takes a single source argument # plus optional keyword args -function make{S}(config, source::S, matcher; debug=false, kargs...) +function make(config, source::S, matcher; debug=false, kargs...) where S I = typeof(start(source)) k = config{S,I}(source; debug=debug, kargs...) (k, Channel(c -> producer(c, k, matcher; debug=debug))) diff --git a/src/core/print.jl b/src/core/print.jl index a1a53be..9fa4a02 100644 --- a/src/core/print.jl +++ b/src/core/print.jl @@ -1,7 +1,7 @@ always_print(::Matcher) = false -print_field{N}(m::Matcher, n::Type{Val{N}}) = "$(N)" +print_field(m::Matcher, n::Type{Val{N}}) where {N} = "$(N)" print_matcher(m::Matcher) = print_matcher(m, Set{Matcher}()) diff --git a/src/core/sugar.jl b/src/core/sugar.jl index 3c26e17..1296a67 100644 --- a/src/core/sugar.jl +++ b/src/core/sugar.jl @@ -57,8 +57,8 @@ Opt!(m::Matcher) = Alt!(m, Epsilon()) # repeat via [lo:hi] or [n] -endof{M<:Matcher}(m::M) = typemax(Int) -size{M<:Matcher}(m::M, n) = endof(m) +endof(m::M) where {M<:Matcher} = typemax(Int) +size(m::M, n) where {M<:Matcher} = endof(m) getindex(m::Matcher, r::Int, s::Symbol...) = getindex(m, r:r; s...) function getindex(m::Matcher, r::UnitRange, s::Symbol...) greedy = true diff --git a/src/core/transforms.jl b/src/core/transforms.jl index 6abe6f0..a740db3 100644 --- a/src/core/transforms.jl +++ b/src/core/transforms.jl @@ -3,7 +3,7 @@ # transform successes (Empty and Value) # function must return a Value instance -@auto_hash_equals type Transform<:Delegate +@auto_hash_equals mutable struct Transform<:Delegate name::Symbol matcher::Matcher f::Function @@ -23,7 +23,7 @@ success(k::Config, m::Transform, s, t, i, r::Value) = Success(TransformState(t), # as above, but function also takes iterator -@auto_hash_equals type ITransform<:Delegate +@auto_hash_equals mutable struct ITransform<:Delegate name::Symbol matcher::Matcher f::Function diff --git a/src/core/try.jl b/src/core/try.jl index 53a564d..7f90334 100644 --- a/src/core/try.jl +++ b/src/core/try.jl @@ -79,7 +79,7 @@ end # the Try() matcher that enables backtracking -@auto_hash_equals type Try<:Delegate +@auto_hash_equals mutable struct Try<:Delegate name::Symbol matcher::Matcher Try(matcher) = new(:Try, matcher) @@ -91,25 +91,25 @@ end execute(k::Config, m::Try, s::Clean, i) = error("use Try only with TrySource") -execute{S<:TrySource}(k::Config{S}, m::Try, s::Clean, i) = execute(k, m, TryState(CLEAN), i) +execute(k::Config{S}, m::Try, s::Clean, i) where {S<:TrySource} = execute(k, m, TryState(CLEAN), i) -function execute{S<:TrySource}(k::Config{S}, m::Try, s::TryState, i) +function execute(k::Config{S}, m::Try, s::TryState, i) where S<:TrySource k.source.frozen += 1 Execute(m, s, m.matcher, s.state, i) end -function success{S<:TrySource}(k::Config{S}, m::Try, s::TryState, t, i, r::Value) +function success(k::Config{S}, m::Try, s::TryState, t, i, r::Value) where S<:TrySource k.source.frozen -= 1 Success(TryState(t), i, r) end -function failure{S<:TrySource}(k::Config{S}, m::Try, s::TryState) +function failure(k::Config{S}, m::Try, s::TryState) where S<:TrySource k.source.frozen -= 1 FAILURE end -function dispatch{S<:TrySource}(k::NoCache{S}, s::Success) +function dispatch(k::NoCache{S}, s::Success) where S<:TrySource (parent, parent_state) = pop!(k.stack) expire(k.source, s.iter) try @@ -119,7 +119,7 @@ function dispatch{S<:TrySource}(k::NoCache{S}, s::Success) end end -function dispatch{S<:TrySource}(k::Cache{S}, s::Success) +function dispatch(k::Cache{S}, s::Success) where S<:TrySource parent, parent_state, key = pop!(k.stack) expire(k.source, s.iter) try diff --git a/src/core/types.jl b/src/core/types.jl index 0148dae..71f79f9 100644 --- a/src/core/types.jl +++ b/src/core/types.jl @@ -59,9 +59,9 @@ abstract type Config{S,I} end # defaults for mismatching types and types with no content ==(a::Matcher, b::Matcher) = false -=={T<:Matcher}(a::T, b::T) = true +==(a::T, b::T) where {T<:Matcher} = true ==(a::State, b::State) = false -=={T<:State}(a::T, b::T) = true +==(a::T, b::T) where {T<:State} = true # use an array to handle empty values in a natural way diff --git a/test/bug/deadlock.jl b/test/bug/deadlock.jl index 830ed62..618858c 100644 --- a/test/bug/deadlock.jl +++ b/test/bug/deadlock.jl @@ -1,15 +1,15 @@ using AutoHashEquals -@compat abstract type Graph end +abstract type Graph end -@auto_hash_equals type Node<:Graph +@auto_hash_equals mutable struct Node<:Graph label::String children::Vector{Graph} Node(label, children...) = new(label, Graph[children...]) end -type Cycle<:Graph +mutable struct Cycle<:Graph node::Nullable{Graph} Cycle() = new(Nullable{Graph}()) end diff --git a/test/core/case.jl b/test/core/case.jl index 35dfbb0..d006ee7 100644 --- a/test/core/case.jl +++ b/test/core/case.jl @@ -14,13 +14,13 @@ using AutoHashEquals # every matcher has a name field, which by default is the name of the matcher # (using @with_names changes this to the variable name - see calc.jl) -@auto_hash_equals type Case<:Delegate +@auto_hash_equals mutable struct Case<:Delegate name::Symbol matcher::Matcher Case(matcher) = new(:Case, matcher) end -immutable CaseState<:DelegateState +struct CaseState<:DelegateState state::State end diff --git a/test/core/fix.jl b/test/core/fix.jl index 517da1a..283ec29 100644 --- a/test/core/fix.jl +++ b/test/core/fix.jl @@ -5,16 +5,16 @@ import Base: == signed_prod(lst) = length(lst) == 1 ? lst[1] : Base.prod(lst) signed_sum(lst) = length(lst) == 1 ? lst[1] : Base.sum(lst) -@compat abstract type Node end +abstract type Node end ==(n1::Node, n2::Node) = isequal(n1.val, n2.val) calc(n::Float64) = n -type Inv<:Node val end +mutable struct Inv<:Node val end calc(i::Inv) = 1.0/calc(i.val) -type Prd<:Node val end +mutable struct Prd<:Node val end calc(p::Prd) = signed_prod(map(calc, p.val)) -type Neg<:Node val end +mutable struct Neg<:Node val end calc(n::Neg) = -calc(n.val) -type Sum<:Node val end +mutable struct Sum<:Node val end calc(s::Sum) = signed_sum(map(calc, s.val)) @with_names begin diff --git a/test/core/speed.jl b/test/core/speed.jl index d8f36ca..e90c463 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 +mutable struct A end +mutable struct B end function random_type() if rand(1:2) == 1 diff --git a/test/core/stack.jl b/test/core/stack.jl index df83214..2c91ab0 100644 --- a/test/core/stack.jl +++ b/test/core/stack.jl @@ -16,15 +16,15 @@ stack(0, 10) @time println(stack(0, 100_000)) # stack limit is somewhere around 100,000 (certainly less than 200,000) -@compat abstract type Msg end +abstract type Msg end -type Call<:Msg +mutable struct Call<:Msg before::Function after::Function value::Int end -type Return<:Msg +mutable struct Return<:Msg value::Int end diff --git a/test/gml/errors.jl b/test/gml/errors.jl index 5ef09fe..5538835 100644 --- a/test/gml/errors.jl +++ b/test/gml/errors.jl @@ -14,11 +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{Int64} parse_raw(text) end