Changeset 5 for trunk/UBrainFuck.pas
- Timestamp:
- Feb 9, 2012, 2:51:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UBrainFuck.pas
r3 r5 6 6 7 7 uses 8 Classes, SysUtils, Dialogs ;8 Classes, SysUtils, Dialogs, Forms; 9 9 10 10 type … … 35 35 Input: string; 36 36 InputPosition: Integer; 37 StepCount: Integer; 37 38 procedure Reset; 38 39 procedure SingleStep; … … 48 49 SProgramLowerLimit = 'Program run over lower limit'; 49 50 SProgramUpperLimit = 'Program run over upper limit'; 51 SReadInputError = 'Read input error'; 50 52 51 53 { TBrainFuckInterpreter } … … 60 62 Character: string; 61 63 begin 62 Character := Copy(Input, InputPosition, 1); 63 Result := Ord(Character[1]); 64 Inc(InputPosition); 64 if InputPosition < Length(Input) then begin 65 Character := Copy(Input, InputPosition, 1); 66 Result := Ord(Character[1]); 67 Inc(InputPosition); 68 end else 69 raise Exception.Create(SReadInputError); 65 70 end; 66 71 … … 84 89 Memory[I] := 0; 85 90 SetLength(Loop, 0); 91 StepCount := 0; 86 92 end; 87 93 … … 129 135 end; 130 136 Inc(SourcePosition); 137 Inc(StepCount); 131 138 end; 132 139 … … 134 141 begin 135 142 Reset; 136 while SourcePosition < Length(Source) do 143 while SourcePosition < Length(Source) do begin 137 144 SingleStep; 145 Application.ProcessMessages; 146 end; 138 147 end; 139 148
Note:
See TracChangeset
for help on using the changeset viewer.