
  PROCEDURE [INLINE] clp$scan_balanced_parenthesis
    (    text: clt$command_line;
         start_index: clt$command_line_index;
     VAR end_index: clt$command_line_index);

?? PUSH (LISTEXT := ON) ??

    VAR
      found_char: boolean,
      nesting_level: integer,
      scan_index: integer,
      text_index: clt$command_line_index;

    text_index := start_index;
    nesting_level := 1;
    found_char := TRUE;

  /scan_loop/
    WHILE (nesting_level > 0) AND found_char AND
          (text_index <= STRLENGTH (text)) DO
      #SCAN (clv$isolate_balanced_text, text (text_index, * ), scan_index,
            found_char);
      text_index := scan_index + text_index - 1;
      IF found_char THEN
        CASE text (text_index) OF
        = '"' =
          #SCAN (clv$comment_delimiter, text (text_index + 1, * ), scan_index,
                found_char);
          text_index := scan_index + text_index + $INTEGER (found_char);
        = '''' =
          #SCAN (clv$string_delimiter, text (text_index + 1, * ), scan_index,
                found_char);
          text_index := scan_index + text_index + $INTEGER (found_char);
        = '(' =
          nesting_level := nesting_level + 1;
          text_index := text_index + 1;
        = ')' =
          nesting_level := nesting_level - 1;
          text_index := text_index + 1;
        = $CHAR (9) {HT} , ' ', ',', ';' =
          text_index := text_index + 1;
        ELSE
          text_index := text_index + 1;
        CASEND;
      IFEND;
    WHILEND /scan_loop/;
    end_index := text_index - 1;

  PROCEND clp$scan_balanced_parenthesis;

*copyc clt$command_line
*copyc clt$command_line_index
?? POP ??
*copyc clv$comment_delimiter
*copyc clv$isolate_balanced_text
*copyc clv$string_delimiter
