public static Cons extractVariablesFromDeclarations(Stella_Object declarations) {
    { Cons result = Stella.NIL;

      if (Stella_Object.safePrimaryType(declarations) == Logic.SGT_STELLA_CONS) {
        { Cons declarations000 = ((Cons)(declarations));

          { Stella_Object item = null;
            Cons iter000 = declarations000;

            for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
              item = iter000.value;
              if (Stella_Object.safePrimaryType(item) == Logic.SGT_STELLA_CONS) {
                { Cons item000 = ((Cons)(item));

                  if (Logic.kifVariableP(item000.value)) {
                    result = Cons.cons(item000.value, result);
                  }
                  else {
                    { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                      { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

                        try {
                          Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
                          stream000.nativeStream.println("PARSING ERROR: Non-variable `" + item000.value + "' found where ?variable expected.");
                          Logic.helpSignalPropositionError(stream000, Logic.KWD_ERROR);

                        } finally {
                          Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
                        }
                      }
                      throw ((ParsingError)(ParsingError.newParsingError(stream000.theStringReader()).fillInStackTrace()));
                    }
                  }
                }
              }
              else {
                if (Logic.kifVariableP(item)) {
                  result = Cons.cons(item, result);
                }
              }
            }
          }
        }
      }
      else {
        if (Logic.kifVariableP(declarations)) {
          result = Cons.cons(declarations, result);
        }
        else {
          { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

            { Object old$PrintreadablyP$001 = Stella.$PRINTREADABLYp$.get();

              try {
                Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
                stream001.nativeStream.println("PARSING ERROR: Non-variable `" + declarations + "' found where ?variable expected.");
                Logic.helpSignalPropositionError(stream001, Logic.KWD_ERROR);

              } finally {
                Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$001);
              }
            }
            throw ((ParsingError)(ParsingError.newParsingError(stream001.theStringReader()).fillInStackTrace()));
          }
        }
      }
      return (result.reverse());
    }
  }