Changeset 49 for trunk/Target/UTargetPHP.pas
- Timestamp:
- Jul 12, 2012, 9:56:58 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTargetPHP.pas
r48 r49 57 57 end; 58 58 59 function CheckClear: Boolean; 60 begin 61 Result := (FSourceCode[I] = '[') and (Length(FSourceCode) >= I + 2) and 62 (FSourceCode[I + 1] = '-') and (FSourceCode[I + 2] = ']'); 63 end; 64 59 65 begin 60 66 inherited; … … 66 72 AddLine('$Memory = str_repeat("\0", 30000);'); 67 73 AddLine('$Position = 0;'); 68 for I := 1 to Length(FSourceCode) do begin 74 I := 1; 75 while (I <= Length(FSourceCode)) do begin 69 76 case FSourceCode[I] of 70 77 '>': begin … … 87 94 ',': AddLine('$Memory[$Position] = fgetc(STDIN);'); 88 95 '[': begin 89 AddLine('while($Memory[$Position] != "\0") {'); 90 Inc(Indent); 96 if CheckClear then begin 97 AddLine('$Memory[$Position] = "\0";'); 98 Inc(I, 2); 99 end else begin 100 AddLine('while($Memory[$Position] != "\0") {'); 101 Inc(Indent); 102 end; 91 103 end; 92 104 ']': begin … … 95 107 end; 96 108 end; 109 Inc(I); 97 110 end; 98 111 AddLine('');
Note:
See TracChangeset
for help on using the changeset viewer.