@@ -148,8 +148,35 @@ emptyrn = @reaction_network
148
148
149
149
ReactionSystems generated through `@reaction_network` are complete.
150
150
"""
151
- macro reaction_network (args... )
152
- return :(complete (@network_component $ (args... )))
151
+ # macro reaction_network(args...)
152
+ # return :(complete(@network_component $(args... )))
153
+ # end
154
+ macro reaction_network (name:: Symbol , ex:: Expr )
155
+ complete (make_reaction_system (MacroTools. striplines (ex); name = :($ (QuoteNode (name)))))
156
+ end
157
+
158
+ # allows @reaction_network $name begin ... to interpolate variables storing a name
159
+ macro reaction_network (name:: Expr , ex:: Expr )
160
+ complete (make_reaction_system (MacroTools. striplines (ex); name = :($ (esc (name. args[1 ])))))
161
+ end
162
+
163
+ macro reaction_network (ex:: Expr )
164
+ ex = MacroTools. striplines (ex)
165
+
166
+ # no name but equations: @reaction_network begin ... end ...
167
+ if ex. head == :block
168
+ complete (make_reaction_system (ex))
169
+ else # empty but has interpolated name: @reaction_network $name
170
+ networkname = :($ (esc (ex. args[1 ])))
171
+ return Expr (:block , :(@parameters t),
172
+ :(complete (ReactionSystem (Reaction[], t, [], []; name = $ networkname))))
173
+ end
174
+ end
175
+
176
+ # Returns a empty network (with, or without, a declared name)
177
+ macro reaction_network (name:: Symbol = gensym (:ReactionSystem ))
178
+ return Expr (:block , :(@parameters t),
179
+ :(complete (ReactionSystem (Reaction[], t, [], []; name = $ (QuoteNode (name))))))
153
180
end
154
181
155
182
"""
@@ -161,25 +188,25 @@ macro network_component(name::Symbol, ex::Expr)
161
188
make_reaction_system (MacroTools. striplines (ex); name = :($ (QuoteNode (name))))
162
189
end
163
190
164
- # allows @reaction_network $name begin ... to interpolate variables storing a name
191
+ # allows @network_component $name begin ... to interpolate variables storing a name
165
192
macro network_component (name:: Expr , ex:: Expr )
166
193
make_reaction_system (MacroTools. striplines (ex); name = :($ (esc (name. args[1 ]))))
167
194
end
168
195
169
196
macro network_component (ex:: Expr )
170
197
ex = MacroTools. striplines (ex)
171
198
172
- # no name but equations: @reaction_network begin ... end ...
199
+ # no name but equations: @network_component begin ... end ...
173
200
if ex. head == :block
174
201
make_reaction_system (ex)
175
- else # empty but has interpolated name: @reaction_network $name
202
+ else # empty but has interpolated name: @network_component $name
176
203
networkname = :($ (esc (ex. args[1 ])))
177
204
return Expr (:block , :(@parameters t),
178
205
:(ReactionSystem (Reaction[], t, [], []; name = $ networkname)))
179
206
end
180
207
end
181
208
182
- # Returns a empty network (with, or without, a declared name)
209
+ # Returns a empty network (with, or without, a declared name)
183
210
macro network_component (name:: Symbol = gensym (:ReactionSystem ))
184
211
return Expr (:block , :(@parameters t),
185
212
:(ReactionSystem (Reaction[], t, [], []; name = $ (QuoteNode (name)))))
0 commit comments