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

Method reduce_stack_one_time

src/canonicalize.rs:3485–3504  ·  view source on GitHub ↗
(&self, parse_stack: &'s mut Vec<StackInfo<'a, 'op>>)

Source from the content-addressed store, hash-verified

3483 }
3484
3485 fn reduce_stack_one_time<'s, 'a:'s, 'op:'a>(&self, parse_stack: &'s mut Vec<StackInfo<'a, 'op>>) -> usize {
3486 let mut top_of_stack = parse_stack.pop().unwrap();
3487 // debug!(" ..popped len={} op:'{}/{}', operand: {}",
3488 // top_of_stack.mrow.children().len(),
3489 // show_invisible_op_char(top_of_stack.op_pair.ch), top_of_stack.op_pair.op.priority,
3490 // top_of_stack.is_operand);
3491 let mut mrow = top_of_stack.mrow;
3492 if mrow.children().len() == 1 && CanonicalizeContext::is_ok_to_merge_mrow_child(mrow) {
3493 // should have added at least operator and operand, but input might not be well-formed
3494 // in this case, unwrap the mrow and expose the single child for pushing onto stack
3495 let single_child = top_of_stack.remove_last_operand_from_mrow();
3496 mrow = single_child;
3497 }
3498
3499 let mut top_of_stack = parse_stack.pop().unwrap();
3500 top_of_stack.add_child_to_mrow(mrow, OperatorPair::new()); // mrow on top is "parsed" -- now add it to previous
3501 let prev_priority = top_of_stack.priority();
3502 parse_stack.push(top_of_stack);
3503 return prev_priority;
3504 }
3505
3506 fn is_trig_arg<'a, 'op:'a>(&self, previous_child: Element<'a>, current_child: Element<'a>, parse_stack: &mut Vec<StackInfo<'a, 'op>>) -> bool {
3507 // We have operand-operand and know we want multiplication at this point.

Callers 2

reduce_stackMethod · 0.80
is_trig_argMethod · 0.80

Calls 6

lenMethod · 0.80
add_child_to_mrowMethod · 0.80
priorityMethod · 0.80
popMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected