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 division.
8 *
9 * @author © 1999 DIRAT Laurent
10 * @version 1.0 18/11/1999
11 */
12 public class Divide extends MapsToNAry {
13 /***
14 * The constructor.
15 */
16 public Divide() {
17 super("divide", LinearParserEvent.DIVISION);
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") ||
29 child.identifier.equals("arithTimes") || child.identifier.equals("unaryMinus")) {
30 LinearParserEvent linearParserEvent = new LinearParserEvent(getEventSource());
31 linearParserEvent.setToken(LinearParserEvent.OPEN_PAREN, null);
32 fireLinearParserEvent(linearParserEvent);
33 child.flush();
34 linearParserEvent.setToken(LinearParserEvent.CLOSE_PAREN, null);
35 fireLinearParserEvent(linearParserEvent);
36 }
37 else
38 child.flush();
39 }
40 }