|
83 | 83 |
|
84 | 84 | PrimitiveIfEmpty(abstr_subj, abstr_tru, abstr_fls) -> ( |
85 | 85 | let value_subj = interpret menv venv abstr_subj in |
86 | | - let value_tru = interpret menv venv abstr_tru in |
87 | | - let value_fls = interpret menv venv abstr_fls in |
88 | 86 | match value_subj with |
89 | | - EmptyAbsBlock -> value_tru |
90 | | - | _ -> value_fls |
| 87 | + EmptyAbsBlock -> interpret menv venv abstr_tru |
| 88 | + | _ -> interpret menv venv abstr_fls |
91 | 89 | ) |
92 | 90 |
|
93 | 91 | | PrimitiveIfSame(abstr_subj1, abstr_subj2, abstr_tru, abstr_fls) -> ( |
|
265 | 263 | | Apply(f, NoID, param_list) -> ( |
266 | 264 | print_process "$Apply (NoID)" ; |
267 | 265 | let spec_f = |
268 | | - try |
269 | | - !(Assoclist.get_value (!menv) f) |
270 | | - with |
| 266 | + try !(Assoclist.get_value (!menv) f) with |
271 | 267 | ValueNotFound -> ( |
272 | 268 | report_error ("undefined control sequence '" ^ f ^ "'") ; |
273 | 269 | DummyFunc |
274 | 270 | ) |
275 | 271 | in |
276 | 272 | match spec_f with (* !(menv(f)) *) |
277 | 273 | Func(var_list, abstr_noid, abstr_id, cont_menv_f, cont_venv_f) -> ( |
278 | | - let value_list = interpret_list menv venv param_list in |
279 | | - let loc_list : location list = ref_list value_list in |
280 | | - let menv_new = ref cont_menv_f in |
281 | | - let venv_new = |
282 | | - try |
283 | | - ref (Assoclist.add_list var_list loc_list cont_venv_f) |
284 | | - with |
285 | | - IncorrespondenceOfLength -> ( |
286 | | - report_error ("wrong number of arguments for '" ^ f ^ "'") ; |
287 | | - ref cont_venv_f |
288 | | - ) |
289 | | - in |
290 | | - (* venv_f{ v_1|->l_1, ..., v_n|->l_n } *) |
291 | | - interpret menv venv_new abstr_noid |
292 | | - (* modify 'menv_new' to 'menv' in order to make f globally defined *) |
293 | | - (* modify 'menv' to 'menv_new' in order to make f locally defined *) |
| 274 | + match f with |
| 275 | + (* write individually macros that need other strategy than call-by-value *) |
| 276 | + |
| 277 | + "\\ifempty" -> ( |
| 278 | + match param_list with |
| 279 | + [abstr_b; abstr_tru; abstr_fls] |
| 280 | + -> interpret menv venv (PrimitiveIfEmpty(abstr_b, abstr_tru, abstr_fls)) |
| 281 | + | _ -> ( report_error ("wrong number of arguments for '\\ifempty'") ; EmptyAbsBlock ) |
| 282 | + ) |
| 283 | + |
| 284 | + | "\\ifsame" -> ( |
| 285 | + match param_list with |
| 286 | + [abstr_sa; abstr_sb; abstr_tru; abstr_fls] |
| 287 | + -> interpret menv venv (PrimitiveIfSame(abstr_sa, abstr_sb, abstr_tru, abstr_fls)) |
| 288 | + | _ -> ( report_error ("wrong number of arguments for '\\ifempty'") ; EmptyAbsBlock ) |
| 289 | + ) |
| 290 | + |
| 291 | + | _ -> ( |
| 292 | + let value_list = interpret_list menv venv param_list in |
| 293 | + let loc_list : location list = ref_list value_list in |
| 294 | + let menv_new = ref cont_menv_f in |
| 295 | + let venv_new = |
| 296 | + try |
| 297 | + ref (Assoclist.add_list var_list loc_list cont_venv_f) |
| 298 | + with |
| 299 | + IncorrespondenceOfLength -> ( |
| 300 | + report_error ("wrong number of arguments for '" ^ f ^ "'") ; |
| 301 | + ref cont_venv_f |
| 302 | + ) |
| 303 | + in |
| 304 | + (* venv_f{ v_1|->l_1, ..., v_n|->l_n } *) |
| 305 | + interpret menv venv_new abstr_noid |
| 306 | + (* modify 'menv_new' to 'menv' in order to make f globally defined *) |
| 307 | + (* modify 'menv' to 'menv_new' in order to make f locally defined *) |
| 308 | + ) |
294 | 309 | ) |
295 | 310 | | DummyFunc -> Invalid |
296 | 311 | ) |
|
0 commit comments