Created
May 8, 2017 14:28
-
-
Save KristofferC/5e7f40eecb605c72251a109d7a6122ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MacroTools, Lazy | |
import MacroTools: prewalk | |
using DataStructures | |
function prockey(key) | |
(isa(key, Symbol) || isa(key, String)) && return :($(string(key)) => nothing) | |
@capture(key, (a_:b_) | (a_=>b_) | (a_=b_)) || error("Invalid pgf option $key") | |
isa(a, Symbol) && (a = Expr(:quote, a)) | |
:($a=>$b) | |
end | |
function procmap(d) | |
@capture(d, {xs__}) || return d | |
:(OrderedDict{Any, Any}($(map(prockey, xs)...))) | |
end | |
macro pgf(ex) | |
@>> ex prewalk(procmap) esc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment