-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
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
How to write a template type? #161
Comments
That extra |
I think you can use this function to remove that extra toplevel_string(expr::Expr) = Meta.parse(replace(string(expr), r"^begin([\s\S]*)end$"=>s"\1")) |
This is really a temporary workaround, could you please report this bug to the julia team? I'm afraid I am not able to make it clear to them. |
Is it possible we move the XML tag (e.g., julia> macro amltag(T, t)
return quote
@aml $t struct DataSection{$T}
type::String, att"type"
size::UInt, att"size"
columns::UN{UInt}, att"columns"
text::String, txt""
end
end
end
@amltag (macro with 1 method)
julia> @macroexpand1 @amltag(:R, "PP_R")
quote
#= REPL[3]:3 =#
#= REPL[3]:3 =# @aml "PP_R" struct DataSection{:R}
#= REPL[3]:5 =#
(type::String, att"type")
#= REPL[3]:6 =#
(size::UInt, att"size")
#= REPL[3]:7 =#
(columns::UN{UInt}, att"columns")
#= REPL[3]:8 =#
(text::String, txt"")
end
end I know this is a breaking change, but can we leave it to |
Yeah, this is a breaking change, but I am fine with it if it solves the issue. |
I have several types, they have the same fieldnames, but different names & tags in an XML file, i.e.,
where the only differences between
R
&Rab
are their name & tags. I want to define a template typeDataSection
so that the following codeis automatically generated.
I tried to write an
@amltag
macro but it doesn't work:As you see, there is an extra
$
before"PP_R"
. I don't know if it is Julia's parsing mechanism causes this. If I put$$t
the next line, it reduces to"PP_R"
immediatelyThe text was updated successfully, but these errors were encountered: