Changeset 203 for branches/interpreter2/UParser.pas
- Timestamp:
- Apr 17, 2020, 10:16:25 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/UParser.pas
r202 r203 27 27 function ParseExpressionOperation(Block: TBlock; out ExpressionOperation: TExpressionOperation): Boolean; 28 28 function ParseExpressionOperand(Block: TBlock; out ExpressionOperand: TExpressionOperand): Boolean; 29 function ParseConstantRef(Block: TBlock; out ConstantRef: TConstant): Boolean; 29 30 function ParseConstant(Block: TBlock; out ConstantRef: TConstant): Boolean; 30 31 function ParseVariable(Block: TBlock; out VariableRef: TVariable): Boolean; … … 342 343 else Error('Expression operands needs to be same type.'); 343 344 end else Error('Missing operand.'); 344 end ;345 end else Operand.Free; 345 346 end; 346 347 if not Result then Tokenizer.Pos := LastPos; … … 364 365 Result := True; 365 366 ExpressionOperand := TExpressionOperand.Create; 367 ExpressionOperand.ConstantDirect := Constant; 368 ExpressionOperand.OperandType := otConstantDirect; 369 end else 370 if ParseConstantRef(Block, Constant) then begin 371 Result := True; 372 ExpressionOperand := TExpressionOperand.Create; 366 373 ExpressionOperand.ConstantRef := Constant; 367 ExpressionOperand.OperandType := otConstant ;374 ExpressionOperand.OperandType := otConstantRef; 368 375 end else 369 376 if ParseVariable(Block, Variable) then begin … … 371 378 ExpressionOperand := TExpressionOperand.Create; 372 379 ExpressionOperand.VariableRef := Variable; 373 ExpressionOperand.OperandType := otVariable ;380 ExpressionOperand.OperandType := otVariableRef; 374 381 end else Error('Expected expression operand.'); 375 382 end; 376 383 377 function TParser.ParseConstant (Block: TBlock; out ConstantRef: TConstant384 function TParser.ParseConstantRef(Block: TBlock; out ConstantRef: TConstant 378 385 ): Boolean; 379 386 var … … 389 396 Result := True; 390 397 end; 391 end else 398 end; 399 if not Result then Tokenizer.Pos := LastPos; 400 end; 401 402 function TParser.ParseConstant(Block: TBlock; out ConstantRef: TConstant 403 ): Boolean; 404 var 405 LastPos: TTokenizerPos; 406 Token: TToken; 407 begin 408 Result := False; 409 LastPos := Tokenizer.Pos; 410 Token := Tokenizer.GetNext; 392 411 if Token.Kind = tkNumber then begin 393 412 Result := True; 394 ConstantRef := Block.Constants.AddNew('_C' + IntToStr(Block.Constants.Count));413 ConstantRef := TConstant.Create; 395 414 ConstantRef.TypeRef := Block.GetType('Integer'); 396 415 ConstantRef.Value := TValueInteger.Create; … … 399 418 if Token.Kind = tkString then begin 400 419 Result := True; 401 ConstantRef := Block.Constants.AddNew('_C' + IntToStr(Block.Constants.Count));420 ConstantRef := TConstant.Create; 402 421 ConstantRef.TypeRef := Block.GetType('string'); 403 422 ConstantRef.Value := TValueString.Create;
Note:
See TracChangeset
for help on using the changeset viewer.