diff --git a/src/syntax/Presentations.jl b/src/syntax/Presentations.jl index 9565905a..07393915 100644 --- a/src/syntax/Presentations.jl +++ b/src/syntax/Presentations.jl @@ -58,11 +58,16 @@ compose(f, g) == h == h′ function ExprInterop.fromexpr(ctx::Context, e, ::Type{Presentation}) e.head == :block || error("expected a block to parse into a GATSegment, got: $e") scopelines, eqlines = [], Vector{Expr0}[] - for line in filter(x->!(x isa LineNumberNode), e.args) - @match line begin - Expr(:call, :(==), a, b) => push!(eqlines, [a, b]) - Expr(:comparison, xs...) => push!(eqlines, xs[1:2:end]) - _ => push!(scopelines, line) + for line in e.args + @switch line begin + @case Expr(:call, :(==), a, b) + push!(eqlines, [a, b]) + @case Expr(:comparison, xs...) + er = "Bad comparison $line" + all(((i,v),)-> iseven(i) == (v == :(==)), enumerate(line.args)) || error(er) + push!(eqlines, xs[1:2:end]) + @case _ + push!(scopelines, line) end end scope = GATs.parsetypescope(ctx, scopelines)