We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using MacroTools using MacroTools: textwalk code = """ Rule(x -> -sin(x)) Rule(x -> 1 + tan(x)^2) """; after = textwalk(code) do expr @capture(expr, Rule(v_)) && return v return expr end println(after)
(x->begin -(sin(x)) end) (x->begin 1 + tan(x) ^ 2 end)
The text was updated successfully, but these errors were encountered:
Workaround:
textwalk(code) do expr @capture(expr, Rule(v_)) && return MacroTools.postwalk(MacroTools.unblock, v) return expr end
Though that still changes spacing, and adds extra backets arround sin(x) and arraound the whole expression
sin(x)
(x->-(sin(x))) (x->1 + tan(x) ^ 2)
Sorry, something went wrong.
This is unfortunately due to Base's default parsing/printing of lambdas:
julia> :(x->1) :(x->begin #= REPL[1]:1 =# 1 end)
Would be great to fix, but unfortunately might require a fork of the Expr printing code (though there are likely several reasons to do this).
Alternatively, since Expr(:->, :x, 1) seems to do the right thing, maybe we can just tweak CSTParser to not insert the block / line number.
Expr(:->, :x, 1)
No branches or pull requests
MWE:
Output:
The text was updated successfully, but these errors were encountered: