Changeset 222 for branches/interpreter2/Generators
- Timestamp:
- Nov 25, 2020, 12:18:45 AM (4 years ago)
- Location:
- branches/interpreter2/Generators
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/Generators/UGeneratorCSharp.pas
r221 r222 31 31 procedure GenerateExpressionOperation(Block: TBlock; Expression: TExpressionOperation); 32 32 procedure GenerateExpressionOperand(Block: TBlock; Expression: TExpressionOperand); 33 procedure GenerateExpressionBrackets(Block: TBlock; Expression: TExpressionBrackets); 33 34 procedure GenerateBreak(Block: TBlock; BreakCmd: TBreak); 34 35 procedure GenerateContinue(Block: TBlock; ContinueCmd: TContinue); … … 37 38 procedure GenerateValue(Value: TValue); 38 39 public 39 Prog: TProgram;40 40 procedure Generate; override; 41 end; 41 constructor Create; override; 42 end; 43 42 44 43 45 implementation 46 47 const 48 ExpressionOperatorTextCSharp: array[TExpressionOperator] of string = ('', '+', 49 '-', '*', '/', '/', '%', '&', '^', '|', '<<', 50 '>>', '==', '!=', '<', '>', '<=','>=', '!'); 44 51 45 52 { TGeneratorCSharp } … … 144 151 if Expression is TExpressionOperand then 145 152 GenerateExpressionOperand(Block, TExpressionOperand(Expression)) 153 else 154 if Expression is TExpressionBrackets then 155 GenerateExpressionBrackets(Block, TExpressionBrackets(Expression)) 146 156 else raise Exception.Create('Unknown expression class.'); 147 157 end; … … 154 164 for I := 0 to Expression.Items.Count - 1 do begin 155 165 if I > 0 then begin 156 if Expression.Operation = eoAdd then AddText(' + ') 157 else if Expression.Operation = eoSub then AddText(' - ') 158 else if Expression.Operation = eoEqual then AddText(' == ') 159 else if Expression.Operation = eoNotEqual then AddText(' != '); 166 AddText(' ' + ExpressionOperatorTextCSharp[Expression.Operation] + ' '); 160 167 end; 161 168 GenerateExpression(Block, TExpression(Expression.Items[I])); … … 173 180 else raise Exception.Create('Unsupported exception operand type.'); 174 181 end; 182 end; 183 184 procedure TGeneratorCSharp.GenerateExpressionBrackets(Block: TBlock; 185 Expression: TExpressionBrackets); 186 begin 187 AddText('('); 188 GenerateExpression(Block, Expression.Expression); 189 AddText(')'); 175 190 end; 176 191 … … 233 248 234 249 procedure TGeneratorCSharp.GenerateBlock(ParentBlock: TBlock; Block: TBlock); 235 var236 I: Integer;237 250 begin 238 251 if Block.BeginEnd.Commands.Count > 0 then begin … … 353 366 end; 354 367 368 constructor TGeneratorCSharp.Create; 369 begin 370 inherited; 371 Name := 'CSharp'; 372 FileExt := '.cs'; 373 end; 374 355 375 end. 356 376 -
branches/interpreter2/Generators/UGeneratorPascal.pas
r221 r222 31 31 procedure GenerateExpressionOperation(Block: TBlock; Expression: TExpressionOperation); 32 32 procedure GenerateExpressionOperand(Block: TBlock; Expression: TExpressionOperand); 33 procedure GenerateExpressionBrackets(Block: TBlock; Expression: TExpressionBrackets); 33 34 procedure GenerateBreak(Block: TBlock; BreakCmd: TBreak); 34 35 procedure GenerateContinue(Block: TBlock; ContinueCmd: TContinue); 35 36 procedure GenerateValue(Value: TValue); 36 37 public 37 Prog: TProgram;38 38 procedure Generate; override; 39 constructor Create; override; 39 40 end; 40 41 … … 134 135 if Expression is TExpressionOperand then 135 136 GenerateExpressionOperand(Block, TExpressionOperand(Expression)) 137 else 138 if Expression is TExpressionBrackets then 139 GenerateExpressionBrackets(Block, TExpressionBrackets(Expression)) 136 140 else raise Exception.Create('Unknown expression class.'); 137 141 end; … … 145 149 if I > 0 then begin 146 150 AddText(' '); 147 if Expression.Operation = eoAdd then AddText('+') 148 else if Expression.Operation = eoSub then AddText('-') 149 else if Expression.Operation = eoEqual then AddText('=') 150 else if Expression.Operation = eoNotEqual then AddText('<>'); 151 AddText(ExpressionOperatorText[Expression.Operation]); 151 152 AddText(' '); 152 153 end; … … 165 166 else raise Exception.Create('Unsupported exception operand type.'); 166 167 end; 168 end; 169 170 procedure TGeneratorPascal.GenerateExpressionBrackets(Block: TBlock; 171 Expression: TExpressionBrackets); 172 begin 173 AddText('('); 174 GenerateExpression(Block, Expression.Expression); 175 AddText(')'); 167 176 end; 168 177 … … 313 322 end; 314 323 324 constructor TGeneratorPascal.Create; 325 begin 326 inherited; 327 Name := 'Pascal'; 328 FileExt := '.pas'; 329 end; 330 315 331 end. 316 332 -
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 -
branches/interpreter2/Generators/UGeneratorXml.pas
r221 r222 16 16 procedure GenerateNode(SourceNode: TSourceNode); 17 17 public 18 Prog: TProgram;19 18 procedure Generate; override; 19 constructor Create; override; 20 20 end; 21 21 … … 73 73 end; 74 74 75 constructor TGeneratorXml.Create; 76 begin 77 inherited; 78 Name := 'XML'; 79 FileExt := '.xml'; 80 end; 81 75 82 end. 76 83
Note:
See TracChangeset
for help on using the changeset viewer.