Changeset 20 for trunk/Compiler/UCompilerPHP.pas
- Timestamp:
- Feb 11, 2012, 10:56:03 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/UCompilerPHP.pas
r19 r20 31 31 var 32 32 I: Integer; 33 Sum: Integer; 34 35 function CheckOccurence(C: Char): Integer; 36 begin 37 Result := 1; 38 if Optimization = coNormal then 39 while ((I + 1) <= Length(Source)) and (Source[I + 1] = C) do begin 40 Inc(Result); 41 Inc(I) 42 end; 43 end; 44 33 45 begin 34 46 Indent := 0; … … 41 53 for I := 1 to Length(Source) do begin 42 54 case Source[I] of 43 '>': AddLine('$Position++;'); 44 '<': AddLine('$Position--;'); 45 '+': AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) + 1);'); 46 '-': AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) - 1);'); 55 '>': begin 56 Sum := CheckOccurence('>'); 57 AddLine('$Position = $Position + ' + IntToStr(Sum) + ';'); 58 end; 59 '<': begin 60 Sum := CheckOccurence('<'); 61 AddLine('$Position = $Position - ' + IntToStr(Sum) + ';'); 62 end; 63 '+': begin 64 Sum := CheckOccurence('+'); 65 AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) + ' + IntToStr(Sum) + ');'); 66 end; 67 '-': begin 68 Sum := CheckOccurence('-'); 69 AddLine('$Memory[$Position] = chr(ord($Memory[$Position]) - ' + IntToStr(Sum) + ');'); 70 end; 47 71 '.': AddLine('echo($Memory[$Position]);'); 48 72 ',': AddLine('$Memory[$Position] = fgetc(STDIN);');
Note:
See TracChangeset
for help on using the changeset viewer.