Changeset 222 for branches/interpreter2/Generators/UGeneratorPhp.pas
- Timestamp:
- Nov 25, 2020, 12:18:45 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/Generators/UGeneratorPhp.pas
r221 r222 30 30 procedure GenerateExpressionOperation(Block: TBlock; Expression: TExpressionOperation); 31 31 procedure GenerateExpressionOperand(Block: TBlock; Expression: TExpressionOperand); 32 procedure GenerateExpressionBrackets(Block: TBlock; Expression: TExpressionBrackets); 32 33 procedure GenerateBreak(Block: TBlock; BreakCmd: TBreak); 33 34 procedure GenerateReturn(Block: TBlock; Return: TReturn); … … 35 36 procedure GenerateValue(Value: TValue); 36 37 public 37 Prog: TProgram;38 38 procedure Generate; override; 39 end; 39 constructor Create; override; 40 end; 41 40 42 41 43 implementation 44 45 const 46 ExpressionOperatorTextPhp: array[TExpressionOperator] of string = ('', '+', 47 '-', '*', '/', '/', '%', 'and', 'xor', 'or', '<<', 48 '>>', '==', '!=', '<', '>', '<=','>=', '!'); 42 49 43 50 { TGeneratorPhp } … … 142 149 if Expression is TExpressionOperand then 143 150 GenerateExpressionOperand(Block, TExpressionOperand(Expression)) 151 else 152 if Expression is TExpressionBrackets then 153 GenerateExpressionBrackets(Block, TExpressionBrackets(Expression)) 144 154 else raise Exception.Create('Unknown expression class.'); 145 155 end; … … 156 166 else AddText(' + '); 157 167 end 158 else if Expression.Operation = eoSub then AddText(' - ') 159 else if Expression.Operation = eoEqual then AddText(' == ') 160 else if Expression.Operation = eoNotEqual then AddText(' != '); 168 else AddText(' ' + ExpressionOperatorTextPhp[Expression.Operation] + ' '); 161 169 end; 162 170 GenerateExpression(Block, TExpression(Expression.Items[I])); … … 174 182 else raise Exception.Create('Unsupported exception operand type.'); 175 183 end; 184 end; 185 186 procedure TGeneratorPhp.GenerateExpressionBrackets(Block: TBlock; 187 Expression: TExpressionBrackets); 188 begin 189 AddText('('); 190 GenerateExpression(Block, Expression.Expression); 191 AddText(')'); 176 192 end; 177 193 … … 290 306 end; 291 307 308 constructor TGeneratorPhp.Create; 309 begin 310 inherited; 311 Name := 'PHP'; 312 FileExt := '.php'; 313 end; 314 292 315 end. 293 316
Note:
See TracChangeset
for help on using the changeset viewer.