1: doctype "../grammars/EJ.g.etl";
     2: /// the samples are taken from corresponding JSR
     3: /// simple enum
     4: enum public Season { 
     5:   literal winter; 
     6:   literal  spring; 
     7:   literal  summer; 
     8:   literal fall; 
     9: };
    10: /// enum with value
    11: enum public Coin {
    12:     literal penny(1); literal  nickel(5); literal dime(10); literal quarter(25);
    13:     maker Coin(int value) { this.value = value; };
    14:     var private final int value;
    15:     to public int value() { return value; };
    16: };
    17: /// abstract enum sample
    18: enum public abstract Operation {
    19:     literal plus {
    20:       to double eval(double x, double y) { return x + y; };
    21:     };
    22:     literal minus {
    23:       to double eval(double x, double y) { return x - y; };
    24:     };
    25:     literal times {
    26:       to double eval(double x, double y) { return x * y; };
    27:     };
    28:     literal divided_by {
    29:       to double eval(double x, double y) { return x / y; };
    30:     };
    31: 
    32:     /// Perform arithmetic operation represented by this constant
    33:     to abstract double eval(double x, double y);
    34: 
    35:     to public static void main(array[String] args) {
    36:         var double x = Double.parseDouble(args[0]);
    37:         var double y = Double.parseDouble(args[1]);
    38: 
    39:         for (var Iterator[Operation] i = VALUES.iterator() : 
    40:              i.hasNext() : ) 
    41:         {
    42:             var Operation op = i.next();
    43:             System.out.println(x + " " + op + " " + y + 
    44:               " = " + op.eval(x, y));
    45:         };
    46:     };
    47: };