A format for expressing an ordered list of integers is to use a comma separated list of either

 individual integers
 Or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. (The range includes all integers in the interval including both endpoints)
 The range syntax is to be used only for, and for every range that expands to more than two values.
Example

The list of integers:

 -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20
Is accurately expressed by the range expression:

 -6,-3-1,3-5,7-11,14,15,17-20
(And vice-versa).



Task

Expand the range description:

  -6,-3--1,3-5,7-11,14,15,17-20 

Note that the second element above,
is the range from minus 3 to minus 1. 



Related task

   Range extraction


include c:\cxpl\codes;          \intrinsic 'code' declarations
string 0;                       \use zero-terminated strings, instead of MSb
char Str;
int  Char, Inx;
 
 
proc GetCh;                     \Get character from Str
[Char:= Str(Inx);
Inx:= Inx+1;
]; \GetCh
 
 
func GetNum;                    \Get number from Str and return its value
int Neg, Num;
[Neg:= false;
if Char = ^- then [Neg:= true;  GetCh];
Num:= 0;
while Char>=^0 & Char<=^9 do
        [Num:= Num*10 + Char-^0;
        GetCh;
        ];
return if Neg then -Num else Num;
]; \GetNum
 
 
int I, N0, N1;
[Str:= "-6,-3--1,3-5,7-11,14,15,17-20";
Inx:= 0;
GetCh;                          \one character look ahead
loop    [N0:= GetNum;
        IntOut(0,N0);
        case Char of
          ^,:   [GetCh;  ChOut(0,^,)];
          ^-:   [GetCh;
                N1:= GetNum;
                for I:= N0+1 to N1 do   \expand range
                        [ChOut(0,^,);  IntOut(0,I)];
                if Char=^, then [GetCh;  ChOut(0,^,)] else quit]
        other   quit;                   \must be 0 string terminator
        ];
CrLf(0);
]