1 package fr.ove.openmath.jome.ctrl.amto;
2
3 import fr.ove.openmath.jome.ctrl.linear.events.LinearParserEvent;
4 import fr.ove.openmath.jome.ctrl.amto.MapsToNAry;
5
6 /***
7 * The abstract math tree object of the substraction.
8 *
9 * @author © 1999 DIRAT Laurent
10 * @version 1.0 18/11/1999
11 */
12 public class Minus extends MapsToNAry {
13 /***
14 * The constructor.
15 */
16 public Minus() {
17 super("minus", LinearParserEvent.SUBSTRACTION);
18 }
19
20 /***
21 * "Flushes" the specified child.<BR>
22 * According to their father, some children need to be between parenthesis to respect correctness of the
23 * expression. So, when needed, the specified child is "flushed" as if it was between parenthesis.
24 * @param child the child to "flush"
25 * @param index the child index in the list of children of the instance.
26 */
27 protected void flushChild(AbstractMathTreeObject child, int index){
28 if (child.identifier.equals("minus") || child.identifier.equals("plus") || child.identifier.equals("unaryMinus")) {
29 LinearParserEvent linearParserEvent = new LinearParserEvent(getEventSource());
30 linearParserEvent.setToken(LinearParserEvent.OPEN_PAREN, null);
31 fireLinearParserEvent(linearParserEvent);
32 child.flush();
33 linearParserEvent.setToken(LinearParserEvent.CLOSE_PAREN, null);
34 fireLinearParserEvent(linearParserEvent);
35 }
36 else
37 child.flush();
38 }
39 }