Changeset 72 for branches/Transpascal/Compiler/Analyze/UPascalParser.pas
- Timestamp:
- Oct 20, 2010, 11:02:10 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Compiler/Analyze/UPascalParser.pas
r71 r72 47 47 48 48 49 resourcestring 50 SUnknownIdentifier = 'Unknown identificator "%s".'; 51 SIllegalExpression = 'Illegal expression "%s".'; 52 SRedefineIdentifier = 'Identificator "%s" redefinition.'; 53 STypeNotDefined = 'Type "%s" not defined.'; 54 SEndOfDataReached = 'Parser reached to end of input data.'; 55 SUndefinedVariable = 'Undefined variable "%s".'; 56 SUndefinedType = 'Undefined type "%s".'; 57 SUndefinedConstant = 'Undefined constant "%s".'; 58 SUnitNotFound = 'Unit "%s" not found.'; 59 60 49 61 implementation 50 62 … … 63 75 if Assigned(OnGetSource) then begin 64 76 if FOnGetSource(Name, Parser.SourceCodeText) then begin 65 Parser. Init;77 Parser.Process; 66 78 Parser.FileName := Name; 67 79 Parser.OnErrorMessage := OnErrorMessage; … … 192 204 end; 193 205 end else begin 194 ErrorMessage(SUnknownIdentifier, [Identifier] );206 ErrorMessage(SUnknownIdentifier, [Identifier], -1); 195 207 end; 196 208 end; … … 326 338 begin 327 339 Result := nil; 328 ErrorMessage(SUnknownIdentifier, [ReadCode] );340 ErrorMessage(SUnknownIdentifier, [ReadCode], -1); 329 341 end; 330 342 end … … 334 346 begin 335 347 Result := nil; 336 ErrorMessage(SIllegalExpression, [ReadCode] );348 ErrorMessage(SIllegalExpression, [ReadCode], -1); 337 349 end; 338 350 end; … … 454 466 ParseFunctionList(Functions, True) 455 467 else begin 456 ErrorMessage(SUnknownIdentifier, [NextToken] );468 ErrorMessage(SUnknownIdentifier, [NextToken], -1); 457 469 ReadCode; 458 470 end; … … 529 541 end; 530 542 end else 531 ErrorMessage(SRedefineIdentifier, [VariableName] );543 ErrorMessage(SRedefineIdentifier, [VariableName], 0); 532 544 Expect(':'); 533 545 TypeName := ReadCode; 534 546 NewValueType := Parent.Types.Search(TypeName); 535 547 if not Assigned(NewValueType) then 536 ErrorMessage(STypeNotDefined, [TypeName] )548 ErrorMessage(STypeNotDefined, [TypeName], -1) 537 549 else 538 550 for I := 0 to Identifiers.Count - 1 do … … 554 566 NewValueType := Parent.Types.Search(TypeName); 555 567 if not Assigned(NewValueType) then 556 ErrorMessage(STypeNotDefined, [TypeName] )568 ErrorMessage(STypeNotDefined, [TypeName], -1) 557 569 else 558 570 begin … … 611 623 ControlVariable := SourceCode.CommonBlock.Variables.Search(VariableName); 612 624 if not Assigned(ControlVariable) then 613 ErrorMessage(SUndefinedVariable, [VariableName] );625 ErrorMessage(SUndefinedVariable, [VariableName], 0); 614 626 Expect(':='); 615 627 Start.CommonBlock := CommonBlock; … … 653 665 end 654 666 else 655 ErrorMessage(SRedefineIdentifier, [VariableName] );667 ErrorMessage(SRedefineIdentifier, [VariableName], 0); 656 668 Expect(':'); 657 669 TypeName := ReadCode; 658 670 NewValueType := Parent.Types.Search(TypeName); 659 671 if NewValueType = nil then 660 ErrorMessage(STypeNotDefined, [TypeName] )672 ErrorMessage(STypeNotDefined, [TypeName], -1) 661 673 else 662 674 for I := 0 to Identifiers.Count - 1 do … … 714 726 end 715 727 else 716 ErrorMessage(SRedefineIdentifier, [ConstantName] );728 ErrorMessage(SRedefineIdentifier, [ConstantName], 0); 717 729 Expect(':'); 718 730 TypeName := ReadCode; … … 723 735 724 736 if NewValueType = nil then 725 ErrorMessage(STypeNotDefined, [TypeName] )737 ErrorMessage(STypeNotDefined, [TypeName], -1) 726 738 else 727 739 for I := 0 to Identifiers.Count - 1 do … … 800 812 TTypeArray(Result).IndexType := ParseType(TypeList, False); 801 813 if not Assigned(TTypeArray(Result).IndexType) then 802 ErrorMessage(SUndefinedType, [TypeName] );814 ErrorMessage(SUndefinedType, [TypeName], 0); 803 815 Expect(']'); 804 816 end; … … 807 819 TTypeArray(Result).ItemType := ParseType(TypeList, False); 808 820 if not Assigned(TTypeArray(Result).ItemType) then 809 ErrorMessage(SUndefinedType, [TypeName] );821 ErrorMessage(SUndefinedType, [TypeName], 0); 810 822 end else 811 823 if NextToken = '^' then begin … … 834 846 TType(Result).UsedType := TypeList.Search(TypeName); 835 847 if not Assigned(TType(Result).UsedType) then 836 ErrorMessage(SUndefinedType, [TypeName] );848 ErrorMessage(SUndefinedType, [TypeName], 0); 837 849 end else begin 838 850 TType(Result) := TypeList.Search(TypeName); 839 851 if not Assigned(TType(Result)) then 840 ErrorMessage(SUndefinedType, [TypeName] );852 ErrorMessage(SUndefinedType, [TypeName], 0); 841 853 end; 842 854 end; … … 922 934 constructor TPascalParser.Create; 923 935 begin 936 inherited; 924 937 end; 925 938 … … 949 962 Exported := AExported; 950 963 end else begin 951 ErrorMessage(SUnitNotFound, [Name] );964 ErrorMessage(SUnitNotFound, [Name], -2); 952 965 SourceCode.Delete(SourceCode.Count - 1); 953 966 end; … … 966 979 if not Assigned(Module) then begin 967 980 if not ParseFile(Name) then begin 968 ErrorMessage(SUnitNotFound, [Name] );981 ErrorMessage(SUnitNotFound, [Name], -2); 969 982 SourceCode.Delete(SourceCode.Count - 1); 970 983 end;
Note:
See TracChangeset
for help on using the changeset viewer.