int .Scan_line( line{}, token_vec[]{} )

    \ Scan the line, breaking it into tokens according to
    \ the delimiters and checking that the meta-characters
    \ are used properly.
    \ The token_count is returned if no errors else -1.
  {
    unsigned    c, i, j, in_quotes, error, is_option;
    unsigned    meta_char{}, delim{}, temp{};
    int         token_count;

    delim = " *t";
    meta_char = "-+=<>}";
    temp = .Alloc_str( 255 );
    i = error = is_option = j = in_quotes = 0;
    token_count = 0;
    if( line{0} == '!' ) .Shift_left( line, 1 );

    repeat
      {
        if( !(c = line{i}) ||  !in_quotes && .Any(c, delim) )
          {
            ++i;
            if( j )
              { \ package current token
                if( token_count >= 40 )
                  {
                    error = 1;
                    break;
                  }
                temp{j} = '*0';
                token_vec[token_count++] = .Copy_str( temp );
                is_option = j = 0;
              }
            if( c ) next;
            break;
          }
        if( !in_quotes && .Any(c, meta_char) )
          {
            select( c )
              {
                case '<':
                case '+':
                case '-': if( j != 0 ) error = 1;
                                else ++is_option;
                case '=': if( ++is_option > 1 ) error = 1;

                case '>':
                case '}': if( j > 1 || j == 1 && temp{0} != c )
                                error = 1;
              }
            if( error ) break;
          }
        if( c == '"' )
          {
            if( in_quotes && (c = line{++i}) != '"' )
              {
                if( !.Any(c, delim) && c ) break;
                in_quotes = 0;
                next;
              }
            ++in_quotes;
          }
        if( j >= 255 )
          {
            error = 1;
            break;
          }
        temp{j++} = c;
        ++i;
      }
    if( in_quotes || error )
        while( token_count-->0 ) .Free( token_vec[token_count] );

    .Free( temp );
    return( token_count );
  }
