Newline macros
This is my current attempt at https://github.com/JuliaLang/JuliaSyntax.jl/issues/436, sorry it took me a little while to post it @c42f.
Lots of things work, but the main problem currently is that my criterion for detecting cases like (@foo x) is too broad. Specifically, cases like this aren't doing what we want:
julia> """
(@foo function bar()
@baz x
y
end)
""" |> Meta.parse
:(#= none:1 =# @foo function bar()
#= none:1 =#
#= none:2 =#
#= none:2 =# @baz x y
end)
Basically, it's detecting that (@foo is matching the desired pattern, but then its also recursively applying the new parsing rule to @baz x and grabbing the y incorrectly.
I haven't yet figured out the right way to fix this.
Heya, we just moved JuliaSyntax into Base in https://github.com/JuliaLang/julia/pull/59870 - if you want to re-propose this PR over there, I've created a branch https://github.com/JuliaLang/JuliaSyntax.jl/tree/pr-for-Base/475 to make this easier.
To make use of the branch, you can use the following steps:
- Clone JuliaLang/julia
- Add JuliaSyntax as a git remote
- Check out pr-for-Base/475
- Rebase on top of master
For example:
# git clone [email protected]:JuliaLang/julia julia_dir
# cd julia_dir
git remote add JuliaSyntax [email protected]:JuliaLang/JuliaSyntax.jl
git fetch JuliaSyntax
git checkout pr-for-Base/475
git rebase origin/master
Sorry this wasn't dealt with prior to the big move!
Thanks Claire! I was actually just looking at this again the other day. I'm still a bit stuck. I've gotten it to a point where I've fixed the problem shown in the original post here, but this case still regresses:
parsestmt(Expr, """
Ex(@a, function @g
@la
end)
""")
I'll post my updated idea and maybe you can tell me if I'm just completely taking the wrong approach
Nevermind, I figured it out and opened a PR!