1: doctype "../grammars/EJ.g.etl" context "MethodContent";
     2: // for loop
     3: var int i;
     4: for(i=0 : i<a.length : i++)
     5: {
     6:   if(a[i] == null)
     7:   {
     8:     break;
     9:   };
    10:   System.out.println("a["+i+"] = "+a[i]);
    11:   continue;
    12: };
    13: for(var int i=0 : i<a.length : i++)
    14: {
    15:   if(a[i] == null)
    16:   {
    17:     break;
    18:   };
    19:   System.out.println("a["+i+"] = "+a[i]);
    20:   continue;
    21: };
    22: // for loop with label
    23: for myLoop (var int i=0 : i<a.length : i++)
    24: {
    25:   if(a[i] == null)
    26:   {
    27:     break myLoop;
    28:   };
    29:   System.out.println("a["+i+"] = "+a[i]);
    30:   continue myLoop;
    31: };
    32: 
    33: 
    34: // foreach loop over integer range
    35: foreach myLoop (int i from 0 to a.length)
    36: {
    37:   if(a[i] == null)
    38:   {
    39:     break myLoop;
    40:   };
    41:   System.out.println("a["+i+"] = "+a[i]);
    42:   continue myLoop;
    43: };
    44: // foreach loop over array
    45: var int i = 0;
    46: foreach(Object o in a)
    47: {
    48:   if(a[i] == null)
    49:   {
    50:     break;
    51:   };
    52:   System.out.println("a["+ i +"] = "+o);
    53:   i++;
    54:   continue;
    55: };
    56: // foreach loop over collections
    57: foreach(Shape s in shapes)
    58: {
    59:   s.draw();
    60: };
    61: // while loop
    62: while(a<b)
    63: {
    64:   System.out.println("b > a by "+(b-a));
    65:   b--; 
    66: };
    67: while myLoop (a < b)
    68: {
    69:   System.out.println("b > a by "+(b-a));
    70:   b--; 
    71:   if( b < 0)
    72:   {
    73:     System.out.println("could not fall below floor");
    74:     break myLoop;
    75:   }; 
    76: };
    77: 
    78: do
    79: {
    80:   System.out.println("b > a by "+(b-a));
    81:   b--; 
    82: } while(a<b);
    83: 
    84: do myLoop 
    85: {
    86:   System.out.println("b > a by "+(b-a));
    87:   b--; 
    88:   if( b < 0)
    89:   {
    90:     System.out.println("could not fall below floor");
    91:     break myLoop;
    92:   }; 
    93: } while (a < b);
    94: