MCPcopy Create free account
hub / github.com/daisy/MathCAT / lift_function_name

Function lift_function_name

src/infer_intent.rs:354–379  ·  view source on GitHub ↗

lift the children up to LITERAL_NAME

(doc: Document<'m>, function_name: Element<'m>, children: Vec<Element<'m>>)

Source from the content-addressed store, hash-verified

352
353/// lift the children up to LITERAL_NAME
354fn lift_function_name<'m>(doc: Document<'m>, function_name: Element<'m>, children: Vec<Element<'m>>) -> Element<'m> {
355 // debug!(" lift_function_name: {}", name(&function_name));
356 // debug!(" lift_function_name: {}", mml_to_string(&function_name));
357 if is_leaf(function_name) {
358 // simple/normal case of f(x,y)
359 set_mathml_name(function_name, as_text(function_name));
360 function_name.set_text("");
361 function_name.replace_children(children);
362 if name(&function_name).find(|ch| ch!='_' && ch!='-').is_none() {
363 let properties = function_name.attribute_value(INTENT_PROPERTY).unwrap_or(":").to_owned();
364 function_name.set_attribute_value(INTENT_PROPERTY, &(properties + "silent:"));
365 }
366 return function_name;
367 } else if function_name.children().is_empty() {
368 // "... :property(...)" -- no function name
369 function_name.replace_children(children);
370 return function_name;
371 } else {
372 // more complicated case of nested name: f(x)(y,z)
373 // create an apply_function(f(x), y, z)
374 let result = create_mathml_element(&doc, IMPLICIT_FUNCTION_NAME);
375 result.append_child(function_name);
376 result.append_children(children);
377 return result;
378 }
379}
380
381
382/// look for @arg=name in mathml

Callers 1

build_functionFunction · 0.85

Calls 6

is_leafFunction · 0.85
set_mathml_nameFunction · 0.85
as_textFunction · 0.85
nameFunction · 0.85
create_mathml_elementFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected