Open singularitti opened 3 years ago
That extra $
was fixable somehow. I have forgotten how to do that.
I think you can use this function to remove that extra $
. This is a bug in Julia. I applied a similar workaround in CompileBot.jl
toplevel_string(expr::Expr) = Meta.parse(replace(string(expr), r"^begin([\s\S]*)end$"=>s"\1"))
I think you can use this function to remove that extra
$
. This is a bug in Julia. I applied a similar workaround in CompileBot.jltoplevel_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., "PP_R"
) before struct
? It solves the problem pretty fine:
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 AcuteML
v1.0?
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"
immediately