docs: function toplevel (text) {
    var state = 0;
    var bracecount = 0;
    var section = new TopLevel ();
    for (var i = 0;  i < text.length;  i++) {
      if (state === 0) {
        // Toplevel.
        if (text[i] === '{' && text[i+1] && text[i+1] === '{') {
          if (text[i+2] !== '[') {
            // The trigger matches; we enter a control zone.
            //
            //   outer {{ control zone }} outer
            //         ^-----------------^
            section.zone = new ControlZone ();
            section.zone.from = i;
            state = 1;
            i += 1;     // Counting the for loop, i will be just after the curly.
          } else {
            // This is an escape.
            // {{[ needs to be converted to {{.
            section.escapes.push (i, i + 3, 0);
            i += 2;     // Counting the for loop, i will be just after the [.
          }
        } else if (text[i] === ']' && text[i+1] && text[i+1] === '}'
            && text[i+2] && text[i+2] === '}') {
          // This is an escape.
          // ]}} needs to be converted to }}.
          section.escapes.push (i, i + 3, 1);
          i += 2;     // Counting the for loop, i will be just after the curly.
        }
      } else if (state === 1) {
        // Inside the control zone.
        if (text[i] === '}' && text[i+1] && text[i+1] === '}') {
          if (bracecount > 0) {
            bracecount -= 1;
            i += 1;
          } else {
            // We leave the control zone.
            section.zone.to = i + 2;
            return section;
          }
        } else if (text[i] === ']' && text[i+1] && text[i+1] == '}'
            && text[i+2] && text[i+2] === '}') {
          // This is an escape.
          // ]}} needs to be converted to }}.
          section.zone.escapes.push (i, i + 3, 1);
          i += 2;
        } else if (text[i] === '{' && text[i+1] && text[i+1] == '{') {
          // Opening a subsection.
          if (text[i+2] && text[i+2] !== '[') {
            bracecount += 1;
            i += 1;
          } else {
            // This is an escape.
            // {{[ needs to be converted to {{.
            section.zone.escapes.push (i, i + 3, 0);
            i += 2;
          }
        }
      }
    }
    return section;
  }