@@ -22,15 +22,13 @@ function _model_macro(mod, name, expr, isconnector)
2222 ext = Ref {Any} (nothing )
2323 eqs = Expr[]
2424 icon = Ref {Union{String, URI}} ()
25- vs = []
26- ps = []
27- kwargs = []
25+ kwargs, ps, sps, vs, = [], [], [], []
2826
2927 for arg in expr. args
3028 arg isa LineNumberNode && continue
3129 if arg. head == :macrocall
3230 parse_model! (exprs. args, comps, ext, eqs, icon, vs, ps,
33- dict, mod, arg, kwargs)
31+ sps, dict, mod, arg, kwargs)
3432 elseif arg. head == :block
3533 push! (exprs. args, arg)
3634 elseif isconnector
@@ -213,8 +211,8 @@ function get_var(mod::Module, b)
213211 end
214212end
215213
216- function parse_model! (exprs, comps, ext, eqs, icon, vs, ps, dict ,
217- mod, arg, kwargs)
214+ function parse_model! (exprs, comps, ext, eqs, icon, vs, ps, sps ,
215+ dict, mod, arg, kwargs)
218216 mname = arg. args[1 ]
219217 body = arg. args[end ]
220218 if mname == Symbol (" @components" )
@@ -225,6 +223,8 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, dict,
225223 parse_variables! (exprs, vs, dict, mod, body, :variables , kwargs)
226224 elseif mname == Symbol (" @parameters" )
227225 parse_variables! (exprs, ps, dict, mod, body, :parameters , kwargs)
226+ elseif mname == Symbol (" @structural_parameters" )
227+ parse_structural_parameters! (exprs, sps, dict, mod, body, kwargs)
228228 elseif mname == Symbol (" @equations" )
229229 parse_equations! (exprs, eqs, dict, body)
230230 elseif mname == Symbol (" @icon" )
@@ -234,6 +234,24 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, dict,
234234 end
235235end
236236
237+ function parse_structural_parameters! (exprs, sps, dict, mod, body, kwargs)
238+ Base. remove_linenums! (body)
239+ for arg in body. args
240+ MLStyle. @match arg begin
241+ Expr (:(= ), a, b) => begin
242+ push! (sps, a)
243+ push! (kwargs, Expr (:kw , a, b))
244+ dict[:kwargs ][a] = b
245+ end
246+ a => begin
247+ push! (sps, a)
248+ push! (kwargs, a)
249+ dict[:kwargs ][a] = nothing
250+ end
251+ end
252+ end
253+ end
254+
237255function parse_components! (exprs, cs, dict, body, kwargs)
238256 expr = Expr (:block )
239257 varexpr = Expr (:block )
0 commit comments