Skip to content

Commit

Permalink
Precisely set version in which the Julia Parser changed the AST
Browse files Browse the repository at this point in the history
  • Loading branch information
lopezm94 committed Mar 2, 2017
1 parent e0acb1e commit ea48d03
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/SugarBLAS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ macro call(expr::Expr)
esc(:(esc($(wrap(expr)))))
end

#Version 0.6 downwards
#Changes made in Julia parser in v"0.6.0-dev.2613".
#JuliaLang Issue: https://github.com/JuliaLang/julia/pull/20327
"""
Transforms the custom case expression to a string representing the equivalent if-then-else block of code.
"""
construct_case_statement(lines::Vector) = construct_case_statement(lines, Val{VERSION>=v"0.6.0-dev.2613"})
function construct_case_statement(lines::Vector, ::Type{Val{true}})
failproof(s) = s
failproof(s::Char) = string("'",s,"'")
Expand All @@ -85,8 +90,6 @@ function construct_case_statement(lines::Vector, ::Type{Val{true}})
exec *= (line.args[2] == :otherwise) && ("else\n$(failproof(line.args[3]))\n")
exec *= "end"
end

#Version 0.6 upwards
function construct_case_statement(lines::Vector, ::Type{Val{false}})
failproof(s) = s
failproof(s::Char) = string("'",s,"'")
Expand All @@ -102,12 +105,6 @@ function construct_case_statement(lines::Vector, ::Type{Val{false}})
exec *= "end"
end

"""
Transforms the custom case expression to a string representing the equivalent if-then-else block of code.
"""
construct_case_statement(lines::Vector) = construct_case_statement(lines, Val{VERSION>=v"0.6.0-dev"})


"""
Sugar for if-then-else expression. Beautiful for one liners.
"""
Expand Down

0 comments on commit ea48d03

Please sign in to comment.