52704.fb2
Move := 0;
StrInx := Instate := StartScanning;
{считывание всех символов строки}
while StrInx <= length(S) do
begin
{извлечь текущий символ}
Ch := S[StrInx];
{обработать в зависимости от состояния}
case State of
StartScanning : begin
case Move of
0 : {переход к ScannedSign по ветви +}
begin
if (Ch = '+') then begin
PushChoice(ChoiceStack, StrInx, Move, State);
State := ScannedSign;
Move := 0;
inc(StrInx);
end else
inc(Move);
end;
1 : {переход к ScannedSign по ветви -}
begin
if (Ch = '-') then begin
PushChoice(ChoiceStack, StrInx, Move, State);
State := ScannedSign;
Move := 0;
inc(StrInx);
end else
inc(Move);
end;
2 : {бесплатный переход к ScannedSign}
begin
PushChoice(ChoiceStack, StrInx, Move, State);
State ScannedSign;
Move := 0;
end;
else
{для этого состояния допустимые переходы отсутствуют}
Move := -1;
end;
end;
ScannedSign : begin
case Move of
0 : {переход x Scanlnteger с использованием цифры}
begin
if TDIsDigit(Ch) then begin
PushChoice(ChoiceStack, StrInx, Move, State);
State := Scanlnteger;