VBって簡単すぎね?

このエントリーをはてなブックマークに追加
5245
procedure TForm1.Button1Click(Sender: TObject);
var num:Integer;
var p:PChar;
 procedure nextInc(var p:PChar);begin while p^ in[' ',#7] do inc(p); if p^<>#0 then inc(p);end;
 procedure addsub ;forward;
 procedure muldiv;
  procedure factor; begin
  num:=0;
  if p^ = '(' then begin nextInc(p); addsub; if p^<> ')' then Abort;nextInc(p);end
  else while p^ in ['0'..'9'] do begin num:=num*10+StrToInt(p^);Inc(p);end;
  end;
 var save:Integer; oldsym:char;
 begin
  factor;
   while (p^ in ['*','/'] ) do
    begin save:=num;oldsym:=p^; nextInc(p);
     factor;
     case oldsym of
     '*': num:=save*num;
     '/': num:=save div num;
     end;
    end;
 end;
5345:2006/04/29(土) 11:11:06
 procedure addsub;
 var save:Integer; oldsym:char;
 begin
  case p^ of
    '+': begin nextInc(p);MulDiv;      end;
    '-': begin nextInc(p);MulDiv; num:=-num; end;
  else  muldiv;
  end;
  while (p^ in [ '+','-'] ) do
   begin save:=num;oldsym:=p^; nextInc(p);
     muldiv;
    case oldsym of
    '+': num:=save+num;
    '-': num:=save-num;
    end;
   end;
 end;
begin
AllocConsole;
p:=PChar(Edit1.Text);
while p^<>#0 do begin
addsub;
writeln(IntToStr(num));
if p^ in [',' ] then nextInc(p)
else break;
end;
end;
5445:2006/04/29(土) 11:15:44
ダメだ。 空白の無視が巧く動いてないや