code: private void run(IOContext in) {
          IOContext oldInput = input;
          input = in;
          try {
              String incomplete = "";
              while (live) {
                  String prompt;
                  if (isRunningInteractive()) {
                      prompt = testPrompt
                                      ? incomplete.isEmpty()
                                              ? "\u0005" //ENQ
                                              : "\u0006" //ACK
                                      : incomplete.isEmpty()
                                              ? feedback.getPrompt(currentNameSpace.tidNext())
                                              : feedback.getContinuationPrompt(currentNameSpace.tidNext())
                      ;
                  } else {
                      prompt = "";
                  }
                  String raw;
                  try {
                      raw = in.readLine(prompt, incomplete);
                  } catch (InputInterruptedException ex) {
                      //input interrupted - clearing current state
                      incomplete = "";
                      continue;
                  }
                  if (raw == null) {
                      //EOF
                      if (in.interactiveOutput()) {
                          // End after user ctrl-D
                          regenerateOnDeath = false;
                      }
                      break;
                  }
                  String trimmed = trimEnd(raw);
                  if (!trimmed.isEmpty() || !incomplete.isEmpty()) {
                      String line = incomplete + trimmed;
  
                      // No commands in the middle of unprocessed source
                      if (incomplete.isEmpty() && line.startsWith("/") && !line.startsWith("//") && !line.startsWith("/*")) {
                          processCommand(line.trim());
                      } else {
                          incomplete = processSourceCatchingReset(line);
                      }
                  }
              }
          } catch (IOException ex) {
              errormsg("jshell.err.unexpected.exception", ex);
          } finally {
              input = oldInput;
          }
      }
docs: Main loop
  @param in the line input/editing context