@@ -217,12 +217,13 @@ function mtkmodel_macro(mod, name, expr)
217217 icon = Ref {Union{String, URI}} ()
218218 vs = []
219219 ps = []
220+ sps = []
220221 kwargs = []
221222
222223 for arg in expr. args
223224 arg isa LineNumberNode && continue
224225 if arg. head == :macrocall
225- parse_model! (exprs. args, comps, ext, eqs, icon, vs, ps,
226+ parse_model! (exprs. args, comps, ext, eqs, icon, vs, ps, sps,
226227 dict, mod, arg, kwargs)
227228 elseif arg. head == :block
228229 push! (exprs. args, arg)
@@ -249,8 +250,8 @@ function mtkmodel_macro(mod, name, expr)
249250 :($ name = $ Model ((; name, $ (kwargs... )) -> $ exprs, $ dict, false ))
250251end
251252
252- function parse_model! (exprs, comps, ext, eqs, icon, vs, ps, dict ,
253- mod, arg, kwargs)
253+ function parse_model! (exprs, comps, ext, eqs, icon, vs, ps, sps ,
254+ dict, mod, arg, kwargs)
254255 mname = arg. args[1 ]
255256 body = arg. args[end ]
256257 if mname == Symbol (" @components" )
@@ -261,6 +262,8 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, dict,
261262 parse_variables! (exprs, vs, dict, mod, body, :variables , kwargs)
262263 elseif mname == Symbol (" @parameters" )
263264 parse_variables! (exprs, ps, dict, mod, body, :parameters , kwargs)
265+ elseif mname == Symbol (" @structural_parameters" )
266+ parse_structural_parameters! (exprs, sps, dict, mod, body, kwargs)
264267 elseif mname == Symbol (" @equations" )
265268 parse_equations! (exprs, eqs, dict, body)
266269 elseif mname == Symbol (" @icon" )
@@ -270,6 +273,25 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, dict,
270273 end
271274end
272275
276+ function parse_structural_parameters! (exprs, sps, dict, mod, body, kwargs)
277+ Base. remove_linenums! (body)
278+ for arg in body. args
279+ MLStyle. @match arg begin
280+ Expr (:(= ), a, b) => begin
281+ push! (sps, a)
282+ push! (kwargs, Expr (:kw , a, b))
283+ dict[:kwargs ][a] = b
284+ end
285+ a => begin
286+ push! (sps, a)
287+ push! (kwargs, a)
288+ dict[:kwargs ][a] = nothing
289+ @info 285
290+ end
291+ end
292+ end
293+ end
294+
273295function parse_components! (exprs, cs, dict, body, kwargs)
274296 expr = Expr (:block )
275297 varexpr = Expr (:block )
0 commit comments