type tstate=(stBegin,stCommand,stParam,stOption,stError,stEnd,stSpace); var state:tstate=stBegin; str:string; i:integer; strIndex:integer=0; command:string=''; commandSymbols:set of char=['a'..'z','A'..'Z','0'..'9']; params:array of string; paramSymbols:set of char=['a'..'z','A'..'Z','_','0'..'9']; begin readln(str); while true do begin strIndex:=strIndex+1; case state of stBegin:begin if strIndex>length(str) then begin state:=stError; continue; end; if str[strIndex] in commandSymbols then begin state:=stCommand; command:=str[strIndex]; continue; end; if str[strIndex]=' ' then continue; state:=stError; end; stCommand:begin if strIndex>length(str) then begin state:=stEnd; continue; end; command:=command+str[strIndex]; if str[strIndex]=' ' then begin state:=stSpace; continue; end; if str[strIndex] in commandSymbols then continue; state:=stError; end; stSpace:begin if strIndex>length(str) then begin state:=stEnd; continue; end; if str[strIndex] in paramSymbols then begin state:=stParam; setlength(params,length(params)+1); params[length(params)-1]:=str[strIndex]; continue; end; if str[strIndex]=' ' then continue; state:=stError; end; stParam:begin if strIndex>length(str) then begin state:=stEnd; continue; end; params[length(params)-1]:=params[length(params)-1]+str[strIndex]; if str[strIndex]=' ' then begin state:=stSpace; continue; end; if str[strIndex] in paramSymbols then continue; state:=stError; end; stError:begin writeln('-------------------------'); writeln(str); writeln('Error ',strIndex-1); break; end; stEnd:begin writeln('-------------------------'); writeln(str); writeln(command); writeln(); for i:=0 to length(params)-1 do writeln(params[i]); break; end; end; end; end.