Changeset 47 for branches/DelphiToC/Analyze/UPascalParser.pas
- Timestamp:
- Aug 9, 2010, 12:48:14 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Analyze/UPascalParser.pas
r46 r47 424 424 end; 425 425 end; 426 Assign(TExpression(TExpression(Expressions.First).SubItems[1])); 426 if Assigned(TExpression(Expressions.First).SubItems[1]) then 427 Assign(TExpression(TExpression(Expressions.First).SubItems[1])); 427 428 TExpression(Expressions.First).SubItems[1] := nil; 428 429 //ShowMessage(IntToStr(Expressions.Count)); 429 TExpression(Expressions[1]).SubItems[0] := nil; 430 if Expressions.Count > 1 then 431 TExpression(Expressions[1]).SubItems[0] := nil; 430 432 Expressions.Destroy; 431 433 end; … … 473 475 end else 474 476 if Assigned(SourceCode.Methods.Search(FNextToken)) then begin 475 Result := T MethodCall.Create;476 T MethodCall(Result).CommonBlock := SourceCode;477 T MethodCall(Result).Method:= SourceCode.Methods.Search(FNextToken);477 Result := TFunctionCall.Create; 478 TFunctionCall(Result).CommonBlock := SourceCode; 479 TFunctionCall(Result).FunctionRef := SourceCode.Methods.Search(FNextToken); 478 480 ReadCode; 479 // ParseMetVariable(T MethodCall(Result).Target);481 // ParseMetVariable(TFunctionCall(Result).Target); 480 482 end else begin 481 483 Result := nil; … … 560 562 else if FNextToken = 'procedure' then 561 563 ParseFunctionList(Methods) 564 else if FNextToken = 'function' then 565 ParseFunctionList(Methods) 562 566 else begin 563 567 ParseBeginEnd(Code); … … 604 608 with TFunction(Items[Add(TFunction.Create)]) do begin 605 609 Parent := SourceCode.Parent; 606 Expect('procedure'); 610 if FNextToken = 'procedure' then begin 611 Expect('procedure'); 612 HaveResult := False; 613 end else begin 614 Expect('function'); 615 HaveResult := True; 616 end; 607 617 Name := ReadCode; 618 608 619 if FNextToken = '(' then begin 609 620 Expect('('); … … 632 643 end; 633 644 Expect(')'); 645 646 // Parse function result type 647 if HaveResult then begin 648 Expect(':'); 649 TypeName := ReadCode; 650 NewValueType := Parent.Types.Search(TypeName); 651 if not Assigned(NewValueType) then ErrorMessage(STypeNotDefined, [TypeName]) 652 else begin 653 ResultType := NewValueType; 654 with TVariable(Parent.Variables.Items[Parent.Variables.Add(TVariable.Create)]) do begin 655 Name := 'Result'; 656 ValueType := NewValueType; 657 end; 658 end; 659 end; 634 660 end; 635 661 end; 636 662 Expect(';'); 637 ParseCommonBlock(TFunction( Items[Count - 1]));663 ParseCommonBlock(TFunction(Last)); 638 664 end; 639 665 Identifiers.Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.