public static Cons matchPattern(Cons pattern, Cons datum, int datumLength) {
    if (pattern.length() < datumLength) {
      return (Stella.NIL);
    }
    else {
      { Cons formList = Stella.NIL;
        Cons patternCursor = pattern;
        Cons datumCursor = datum;
        Stella_Object patternElement = null;
        Stella_Object datumElement = null;
        boolean optionalP = false;
        Cons matching = Stella.NIL;

        while (!((patternCursor == Stella.NIL) ||
            (datumCursor == Stella.NIL))) {
          patternElement = patternCursor.value;
          datumElement = datumCursor.value;
          optionalP = Stella_Object.isaP(patternElement, Stella.SGT_STELLA_CONS);
          matching = Symbol.matchPatternElement((optionalP ? ((Symbol)(((Cons)(patternElement)).value)) : ((Symbol)(patternElement))), datumElement);
          if (!(matching == Stella.NIL)) {
            { Stella_Object formType = matching.value;

              if (!((formType == Stella.SYM_STELLA_TIME_DIVIDER) ||
                  ((formType == Stella.SYM_STELLA_DATE_DIVIDER) ||
                   (formType == Stella.SYM_STELLA_DATE_TIME_DIVIDER)))) {
                formList = Cons.cons(matching, formList);
              }
            }
          }
          else if (optionalP) {
            datumCursor = Cons.cons(datumElement, datumCursor);
          }
          else {
            return (Stella.NIL);
          }
          patternCursor = patternCursor.rest;
          datumCursor = datumCursor.rest;
        }
        if ((patternCursor == Stella.NIL) &&
            (datumCursor == Stella.NIL)) {
          return (formList.reverse());
        }
        else if (patternCursor == Stella.NIL) {
          return (Stella.NIL);
        }
        else if (datumCursor == Stella.NIL) {
          { Stella_Object element = null;
            Cons iter000 = patternCursor;

            for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
              element = iter000.value;
              if (!Stella_Object.isaP(element, Stella.SGT_STELLA_CONS)) {
                return (Stella.NIL);
              }
            }
          }
          return (formList.reverse());
        }
        else {
          throw ((StellaException)(StellaException.newStellaException("Shouldn't get here!").fillInStackTrace()));
        }
      }
    }
  }