View Javadoc

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.Function;
5   
6   /***
7   * The abstract math tree object of the lambda expression.
8   *
9   * @author © 1999 DIRAT Laurent
10  * @version 1.0  19/11/1999
11  */
12  public class Lambda extends Function {
13      /***
14      * The constructor.
15      * @param identifier the identifier of the instance.
16      * @param token the identifier of the instance by the mean of the event sent.
17      */
18      public Lambda() {
19          super("lambda");
20      }
21      
22      /***
23      * "Flushes" the object as a sequence of events for the building of the model
24      */
25      public void flush() {
26          LinearParserEvent linearParserEvent = new LinearParserEvent(getEventSource());
27          
28          // The opening
29          linearParserEvent.setToken(opening, param);
30          fireLinearParserEvent(linearParserEvent);
31          
32          // we first flush the object of the lambda expression, then the bound variable(s).
33          // (OM has the bound variable(s) first)
34          
35          int nbChildren = getNbChildren();
36          int count = nbChildren - 1;
37          flushChild(getChild(count), count);
38          for (int i = 0; i < count; i++) {
39              linearParserEvent.setToken(token, null);
40              fireLinearParserEvent(linearParserEvent);
41              flushChild(getChild(i), i);
42          }
43          
44          // The closing
45          linearParserEvent.setToken(closing, null);
46          fireLinearParserEvent(linearParserEvent);
47      }
48  }