Skip to content

Commit

Permalink
cleanup ctors of Matcher-derived types
Browse files Browse the repository at this point in the history
so that one ctor calls the lower-level one (to minimize typos)
  • Loading branch information
alyst committed Nov 26, 2019
1 parent 896c626 commit a80b50d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/core/matchers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ end
name::Symbol
matchers::Vector{Matcher}

Seq(m::Matcher...) = new(:Seq, [m...])
Seq(m::Vector{Matcher}) = new(:Seq, m)
Seq(matchers::Vector{Matcher}) = new(:Seq, matchers)
Seq(matchers::Matcher...) = Seq(Matcher[matchers...])
end

serial_success(m::Seq, results::Vector{Value}) = flatten(results)
Expand All @@ -494,8 +494,8 @@ serial_success(m::Seq, results::Vector{Value}) = flatten(results)
name::Symbol
matchers::Vector{Matcher}

And(m::Matcher...) = new(:And, Matcher[m...])
And(m::Vector{Matcher}) = new(:And, m)
And(matchers::Vector{Matcher}) = new(:And, matchers)
And(matchers::Matcher...) = And(Matcher[matchers...])
end

# copy to get type right (Array{Value,1} -> Array{Any,1})
Expand Down Expand Up @@ -559,8 +559,8 @@ abstract type Series! <: Matcher end
name::Symbol
matchers::Vector{Matcher}

Seq!(m::Matcher...) = new(:Seq!, Matcher[m...])
Seq!(m::Vector{Matcher}) = new(:Seq!, m)
Seq!(matchers::Vector{Matcher}) = new(:Seq!, matchers)
Seq!(matchers::Matcher...) = Seq!(Matcher[matchers...])
end

serial_success(m::Seq!, results::Vector{Value}) = flatten(results)
Expand All @@ -569,8 +569,8 @@ serial_success(m::Seq!, results::Vector{Value}) = flatten(results)
name::Symbol
matchers::Vector{Matcher}

And!(m::Matcher...) = new(:And!, Matcher[m...])
ANd!(m::Vector{Matcher}) = new(:And!, m)
And!(matchers::Vector{Matcher}) = new(:And!, matchers)
And!(matchers::Matcher...) = And!(Matcher[matchers...])
end

serial_success(m::And!, results::Vector{Value}) = Any[results...]
Expand Down Expand Up @@ -605,8 +605,8 @@ Alternatives(m::Matcher...; backtrack=true) = backtrack ? Alt(m...) : Alt!(m...)
name::Symbol
matchers::Vector{Matcher}

Alt(matchers::Matcher...) = new(:Alt, Matcher[matchers...])
Alt(matchers::Vector{Matcher}) = new(:Alt, matchers)
Alt(matchers::Matcher...) = Alt(Matcher[matchers...])
end

@auto_hash_equals struct AltState{I} <: State
Expand Down Expand Up @@ -648,8 +648,8 @@ end
name::Symbol
matchers::Vector{Matcher}

Alt!(matchers::Matcher...) = new(:Alt!, Matcher[matchers...])
Alt!(matchers::Vector{Matcher}) = new(:Alt!, matchers)
Alt!(matchers::Matcher...) = Alt!(Matcher[matchers...])
end

@auto_hash_equals struct AltState!{I} <: State
Expand Down Expand Up @@ -735,9 +735,9 @@ failure(k::Config, m::Not, s::NotState) = Success(s, s.iter, EMPTY)
regex::Regex
groups::Tuple

Pattern(r::Regex, group::Int...) = new(:Pattern, r.pattern, Regex("^(?:" * r.pattern * ")(.??)"), group)
Pattern(s::AbstractString, group::Int...) = new(:Pattern, s, Regex("^(?:" * s * ")(.??)"), group)
Pattern(s::AbstractString, flags::AbstractString, group::Int...) = new(:Pattern. s, Regex("^(?:" * s * ")(.??)", flags), group)
Pattern(s::AbstractString, flags::AbstractString, group::Int...) = new(:Pattern, s, Regex("^(?:" * s * ")(.??)", flags), group)
Pattern(r::Regex, group::Int...) = Pattern(r.pattern, group...)
end

print_field(m::Pattern, ::Type{Val{:text}}) = "text=\"$(m.text)\""
Expand Down

0 comments on commit a80b50d

Please sign in to comment.