Changeset 73
- Timestamp:
- Oct 20, 2010, 11:16:02 AM (14 years ago)
- Location:
- branches/Transpascal
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Compiler/Analyze/UParser.pas
r72 r73 85 85 begin 86 86 if NextToken <> Code then begin 87 ErrorMessage(SExpectedButFound, [Code, FNextToken], - 2);87 ErrorMessage(SExpectedButFound, [Code, FNextToken], -1); 88 88 89 89 // Recovery: try to find nearest same code -
branches/Transpascal/Compiler/Analyze/UPascalParser.pas
r72 r73 271 271 begin 272 272 begin 273 if NextToken = 'begin' then 274 begin 273 if NextToken = 'begin' then begin 275 274 Result := TBeginEnd.Create; 276 275 TBeginEnd(Result).CommonBlock := SourceCode; … … 278 277 // + ' ' + IntToStr(Integer(Result))); 279 278 ParseBeginEnd(TBeginEnd(Result)); 280 end 281 else 282 if NextToken = 'if' then 283 begin 279 end else 280 if NextToken = 'if' then begin 284 281 Result := TIfThenElse.Create; 285 282 TIfThenElse(Result).CommonBlock := SourceCode; 286 283 ParseIfThenElse(TIfThenElse(Result)); 287 end 288 else 289 if NextToken = 'while' then 290 begin 284 end else 285 if NextToken = 'while' then begin 291 286 Result := TWhileDo.Create; 292 287 TWhileDo(Result).CommonBlock := SourceCode; 293 288 ParseWhileDo(TWhileDo(Result)); 294 end 295 else 296 if NextToken = 'for' then 297 begin 289 end else 290 if NextToken = 'for' then begin 298 291 Result := TForToDo.Create; 299 292 TForToDo(Result).CommonBlock := SourceCode; 300 293 ParseForToDo(TForToDo(Result)); 301 end 302 else 303 if IsIdentificator(NextToken) then 304 begin 305 if Assigned(SourceCode.Variables.Search(NextToken)) then 306 begin 294 end else 295 if IsIdentificator(NextToken) then begin 296 if Assigned(SourceCode.Variables.Search(NextToken)) then begin 307 297 // Variable assignment 308 298 Result := TAssignment.Create; … … 314 304 TAssignment(Result).Source.CommonBlock := SourceCode; 315 305 ParseExpression(TAssignment(Result).Source); 316 end 317 else 318 if Assigned(SourceCode.Functions.Search(NextToken)) then 319 begin 306 end else 307 if Assigned(SourceCode.Functions.Search(NextToken)) then begin 320 308 // Function call 321 309 FunctionName := ReadCode; … … 334 322 Expect(')'); 335 323 end; 336 end 337 else 338 begin 324 end else begin 339 325 Result := nil; 340 326 ErrorMessage(SUnknownIdentifier, [ReadCode], -1); 341 327 end; 342 end 343 else 328 end else 344 329 if NextToken = ';' then 345 else 346 begin 330 else begin 347 331 Result := nil; 348 332 ErrorMessage(SIllegalExpression, [ReadCode], -1); … … 646 630 I: integer; 647 631 begin 632 try 648 633 Identifiers := TStringList.Create; 649 with SourceCode do 650 begin 634 with SourceCode do begin 651 635 Expect('var'); 652 while IsIdentificator(NextToken) and (NextTokenType <> ttEndOfFile) do 653 begin 636 while IsIdentificator(NextToken) and (NextTokenType <> ttEndOfFile) do begin 654 637 Identifiers.Clear; 655 638 VariableName := ReadCode; 656 639 Variable := Search(VariableName); 657 if not Assigned(Variable) then 658 begin 640 if not Assigned(Variable) then begin 659 641 Identifiers.Add(VariableName); 660 while NextToken = ',' do 661 begin 642 while NextToken = ',' do begin 662 643 Expect(','); 663 644 Identifiers.Add(ReadCode); 664 645 end; 665 end 666 else 646 end else 667 647 ErrorMessage(SRedefineIdentifier, [VariableName], 0); 668 648 Expect(':'); … … 673 653 else 674 654 for I := 0 to Identifiers.Count - 1 do 675 with TVariable(Items[Add(TVariable.Create)]) do 676 begin 655 with TVariable(Items[Add(TVariable.Create)]) do begin 677 656 Name := Identifiers[I]; 678 657 ValueType := NewValueType; … … 681 660 end; 682 661 end; 683 Identifiers.Destroy; 662 finally 663 Identifiers.Free; 664 end; 684 665 end; 685 666 … … 688 669 procedure TPascalParser.ParseVariable(SourceCode: TVariable; Exported: Boolean = False); 689 670 begin 690 with SourceCode do 691 begin 671 with SourceCode do begin 692 672 Name := NextToken; 693 673 Expect(':='); -
branches/Transpascal/Compiler/USourceCode.pas
r71 r73 297 297 function SearchVariable(Name: string; Outside: Boolean): TVariable; virtual; 298 298 function SearchConstant(Name: string; Outside: Boolean): TConstant; virtual; 299 function SearchType( Name: string; Outside: Boolean): TType; virtual;299 function SearchType(AName: string; Outside: Boolean): TType; virtual; 300 300 function SearchFunction(Name: string; Outside: Boolean): TFunction; virtual; 301 301 constructor Create; … … 759 759 end; 760 760 761 function TModule.SearchType( Name: string; Outside: Boolean): TType;762 var 763 I: Integer; 764 begin 765 Result := Body.Types.Search( Name, Outside);761 function TModule.SearchType(AName: string; Outside: Boolean): TType; 762 var 763 I: Integer; 764 begin 765 Result := Body.Types.Search(AName, Outside); 766 766 767 767 if not Assigned(Result) and Outside then begin … … 770 770 with TUsedModule(UsedModules[I]) do 771 771 with Module do 772 Result := SearchType( Name, False);772 Result := SearchType(AName, False); 773 773 Inc(I); 774 774 end; -
branches/Transpascal/Transpascal.lpi
r72 r73 206 206 <TopLine Value="3"/> 207 207 <CursorPos X="50" Y="10"/> 208 <UsageCount Value="13 6"/>208 <UsageCount Value="137"/> 209 209 <Loaded Value="True"/> 210 210 <DefaultSyntaxHighlighter Value="Delphi"/> … … 238 238 <Filename Value="Compiler\USourceCode.pas"/> 239 239 <UnitName Value="USourceCode"/> 240 <IsVisibleTab Value="True"/> 240 241 <EditorIndex Value="10"/> 241 242 <WindowIndex Value="0"/> 242 <TopLine Value=" 472"/>243 <CursorPos X=" 42" Y="482"/>243 <TopLine Value="298"/> 244 <CursorPos X="26" Y="299"/> 244 245 <UsageCount Value="58"/> 245 246 <Loaded Value="True"/> … … 250 251 <EditorIndex Value="3"/> 251 252 <WindowIndex Value="0"/> 252 <TopLine Value=" 155"/>253 <CursorPos X=" 26" Y="163"/>253 <TopLine Value="84"/> 254 <CursorPos X="59" Y="87"/> 254 255 <UsageCount Value="59"/> 255 256 <Loaded Value="True"/> … … 272 273 <TopLine Value="71"/> 273 274 <CursorPos X="20" Y="76"/> 274 <UsageCount Value="12 0"/>275 <UsageCount Value="121"/> 275 276 <DefaultSyntaxHighlighter Value="Delphi"/> 276 277 </Unit24> … … 285 286 <TopLine Value="1"/> 286 287 <CursorPos X="26" Y="17"/> 287 <UsageCount Value="12 0"/>288 <UsageCount Value="121"/> 288 289 <Loaded Value="True"/> 289 290 <LoadedDesigner Value="True"/> … … 296 297 <ResourceBaseClass Value="Form"/> 297 298 <UnitName Value="UMessagesForm"/> 298 <IsVisibleTab Value="True"/>299 299 <EditorIndex Value="4"/> 300 300 <WindowIndex Value="0"/> 301 <TopLine Value=" 62"/>302 <CursorPos X="38" Y="7 5"/>303 <UsageCount Value="12 0"/>301 <TopLine Value="11"/> 302 <CursorPos X="38" Y="76"/> 303 <UsageCount Value="121"/> 304 304 <Loaded Value="True"/> 305 305 <DefaultSyntaxHighlighter Value="Delphi"/> … … 315 315 <TopLine Value="5"/> 316 316 <CursorPos X="28" Y="21"/> 317 <UsageCount Value="1 19"/>317 <UsageCount Value="120"/> 318 318 <DefaultSyntaxHighlighter Value="Delphi"/> 319 319 </Unit27> … … 327 327 <TopLine Value="1"/> 328 328 <CursorPos X="1" Y="1"/> 329 <UsageCount Value="1 19"/>329 <UsageCount Value="120"/> 330 330 <DefaultSyntaxHighlighter Value="Delphi"/> 331 331 </Unit28> … … 357 357 <IsPartOfProject Value="True"/> 358 358 <UnitName Value="URegistry"/> 359 <UsageCount Value="11 2"/>359 <UsageCount Value="113"/> 360 360 <DefaultSyntaxHighlighter Value="Delphi"/> 361 361 </Unit32> … … 364 364 <IsPartOfProject Value="True"/> 365 365 <UnitName Value="ULastOpenedList"/> 366 <UsageCount Value="11 2"/>366 <UsageCount Value="113"/> 367 367 <DefaultSyntaxHighlighter Value="Delphi"/> 368 368 </Unit33> … … 371 371 <IsPartOfProject Value="True"/> 372 372 <UnitName Value="UApplicationInfo"/> 373 <UsageCount Value="11 1"/>373 <UsageCount Value="112"/> 374 374 <DefaultSyntaxHighlighter Value="Delphi"/> 375 375 </Unit34> … … 410 410 <EditorIndex Value="2"/> 411 411 <WindowIndex Value="0"/> 412 <TopLine Value=" 326"/>413 <CursorPos X=" 54" Y="348"/>412 <TopLine Value="637"/> 413 <CursorPos X="1" Y="650"/> 414 414 <UsageCount Value="34"/> 415 415 <Loaded Value="True"/> … … 441 441 <TopLine Value="56"/> 442 442 <CursorPos X="3" Y="69"/> 443 <UsageCount Value=" 10"/>443 <UsageCount Value="9"/> 444 444 </Unit42> 445 445 <Unit43> … … 449 449 <TopLine Value="113"/> 450 450 <CursorPos X="3" Y="120"/> 451 <UsageCount Value=" 10"/>451 <UsageCount Value="9"/> 452 452 </Unit43> 453 453 <Unit44> … … 456 456 <TopLine Value="1"/> 457 457 <CursorPos X="24" Y="11"/> 458 <UsageCount Value=" 10"/>458 <UsageCount Value="9"/> 459 459 </Unit44> 460 460 </Units> 461 <JumpHistory Count=" 28" HistoryIndex="27">461 <JumpHistory Count="30" HistoryIndex="29"> 462 462 <Position1> 463 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>464 <Caret Line=" 400" Column="1" TopLine="384"/>463 <Filename Value="Compiler\USourceCode.pas"/> 464 <Caret Line="772" Column="1" TopLine="751"/> 465 465 </Position1> 466 466 <Position2> 467 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>468 <Caret Line=" 414" Column="1" TopLine="401"/>467 <Filename Value="Compiler\USourceCode.pas"/> 468 <Caret Line="773" Column="1" TopLine="752"/> 469 469 </Position2> 470 470 <Position3> 471 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>472 <Caret Line=" 415" Column="1" TopLine="401"/>471 <Filename Value="Compiler\USourceCode.pas"/> 472 <Caret Line="776" Column="1" TopLine="755"/> 473 473 </Position3> 474 474 <Position4> 475 475 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 476 <Caret Line=" 418" Column="1" TopLine="401"/>476 <Caret Line="650" Column="1" TopLine="637"/> 477 477 </Position4> 478 478 <Position5> 479 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>480 <Caret Line="4 21" Column="1" TopLine="401"/>479 <Filename Value="Compiler\USourceCode.pas"/> 480 <Caret Line="473" Column="1" TopLine="460"/> 481 481 </Position5> 482 482 <Position6> 483 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>484 <Caret Line="4 28" Column="1" TopLine="415"/>483 <Filename Value="Compiler\USourceCode.pas"/> 484 <Caret Line="475" Column="1" TopLine="460"/> 485 485 </Position6> 486 486 <Position7> 487 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>488 <Caret Line="4 29" Column="1" TopLine="415"/>487 <Filename Value="Compiler\USourceCode.pas"/> 488 <Caret Line="485" Column="1" TopLine="469"/> 489 489 </Position7> 490 490 <Position8> 491 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>492 <Caret Line=" 431" Column="1" TopLine="415"/>491 <Filename Value="Compiler\USourceCode.pas"/> 492 <Caret Line="764" Column="1" TopLine="751"/> 493 493 </Position8> 494 494 <Position9> 495 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>496 <Caret Line=" 433" Column="1" TopLine="415"/>495 <Filename Value="Compiler\USourceCode.pas"/> 496 <Caret Line="765" Column="1" TopLine="751"/> 497 497 </Position9> 498 498 <Position10> 499 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>500 <Caret Line=" 435" Column="1" TopLine="415"/>499 <Filename Value="Compiler\USourceCode.pas"/> 500 <Caret Line="767" Column="1" TopLine="751"/> 501 501 </Position10> 502 502 <Position11> 503 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>504 <Caret Line=" 437" Column="1" TopLine="416"/>503 <Filename Value="Compiler\USourceCode.pas"/> 504 <Caret Line="768" Column="1" TopLine="751"/> 505 505 </Position11> 506 506 <Position12> 507 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>508 <Caret Line=" 439" Column="1" TopLine="418"/>507 <Filename Value="Compiler\USourceCode.pas"/> 508 <Caret Line="769" Column="1" TopLine="751"/> 509 509 </Position12> 510 510 <Position13> 511 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>512 <Caret Line=" 441" Column="1" TopLine="420"/>511 <Filename Value="Compiler\USourceCode.pas"/> 512 <Caret Line="770" Column="1" TopLine="751"/> 513 513 </Position13> 514 514 <Position14> 515 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>516 <Caret Line=" 445" Column="17" TopLine="424"/>515 <Filename Value="Compiler\USourceCode.pas"/> 516 <Caret Line="771" Column="1" TopLine="751"/> 517 517 </Position14> 518 518 <Position15> 519 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>520 <Caret Line=" 481" Column="3" TopLine="477"/>519 <Filename Value="Compiler\USourceCode.pas"/> 520 <Caret Line="772" Column="1" TopLine="751"/> 521 521 </Position15> 522 522 <Position16> 523 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>524 <Caret Line=" 487" Column="1" TopLine="477"/>523 <Filename Value="Compiler\USourceCode.pas"/> 524 <Caret Line="764" Column="1" TopLine="751"/> 525 525 </Position16> 526 526 <Position17> 527 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>528 <Caret Line=" 488" Column="1" TopLine="477"/>527 <Filename Value="Compiler\USourceCode.pas"/> 528 <Caret Line="765" Column="1" TopLine="751"/> 529 529 </Position17> 530 530 <Position18> 531 531 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 532 <Caret Line=" 491" Column="1" TopLine="477"/>532 <Caret Line="650" Column="1" TopLine="637"/> 533 533 </Position18> 534 534 <Position19> 535 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>536 <Caret Line="4 87" Column="1" TopLine="477"/>535 <Filename Value="Compiler\USourceCode.pas"/> 536 <Caret Line="473" Column="1" TopLine="460"/> 537 537 </Position19> 538 538 <Position20> 539 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>540 <Caret Line="4 88" Column="1" TopLine="477"/>539 <Filename Value="Compiler\USourceCode.pas"/> 540 <Caret Line="475" Column="1" TopLine="460"/> 541 541 </Position20> 542 542 <Position21> 543 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>544 <Caret Line="4 91" Column="1" TopLine="477"/>543 <Filename Value="Compiler\USourceCode.pas"/> 544 <Caret Line="476" Column="1" TopLine="460"/> 545 545 </Position21> 546 546 <Position22> 547 <Filename Value="Compiler\ Analyze\UParser.pas"/>548 <Caret Line=" 317" Column="1" TopLine="304"/>547 <Filename Value="Compiler\USourceCode.pas"/> 548 <Caret Line="485" Column="1" TopLine="464"/> 549 549 </Position22> 550 550 <Position23> 551 <Filename Value="Compiler\ Analyze\UParser.pas"/>552 <Caret Line=" 326" Column="33" TopLine="304"/>551 <Filename Value="Compiler\USourceCode.pas"/> 552 <Caret Line="764" Column="1" TopLine="751"/> 553 553 </Position23> 554 554 <Position24> 555 <Filename Value="Compiler\ Analyze\UParser.pas"/>556 <Caret Line=" 170" Column="1" TopLine="157"/>555 <Filename Value="Compiler\USourceCode.pas"/> 556 <Caret Line="765" Column="1" TopLine="751"/> 557 557 </Position24> 558 558 <Position25> 559 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>560 <Caret Line=" 356" Column="1" TopLine="343"/>559 <Filename Value="Compiler\USourceCode.pas"/> 560 <Caret Line="767" Column="1" TopLine="751"/> 561 561 </Position25> 562 562 <Position26> 563 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>564 <Caret Line=" 433" Column="1" TopLine="420"/>563 <Filename Value="Compiler\USourceCode.pas"/> 564 <Caret Line="768" Column="1" TopLine="751"/> 565 565 </Position26> 566 566 <Position27> 567 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>568 <Caret Line=" 51" Column="3" TopLine="33"/>567 <Filename Value="Compiler\USourceCode.pas"/> 568 <Caret Line="769" Column="1" TopLine="751"/> 569 569 </Position27> 570 570 <Position28> 571 <Filename Value=" Forms\UMessagesForm.pas"/>572 <Caret Line="7 5" Column="28" TopLine="62"/>571 <Filename Value="Compiler\USourceCode.pas"/> 572 <Caret Line="770" Column="1" TopLine="751"/> 573 573 </Position28> 574 <Position29> 575 <Filename Value="Compiler\USourceCode.pas"/> 576 <Caret Line="771" Column="1" TopLine="751"/> 577 </Position29> 578 <Position30> 579 <Filename Value="Compiler\USourceCode.pas"/> 580 <Caret Line="761" Column="32" TopLine="751"/> 581 </Position30> 574 582 </JumpHistory> 575 583 </ProjectOptions> … … 617 625 </CompilerOptions> 618 626 <Debugging> 627 <BreakPoints Count="1"> 628 <Item1> 629 <Source Value="Compiler\Analyze\UPascalParser.pas"/> 630 <Line Value="650"/> 631 </Item1> 632 </BreakPoints> 619 633 <Exceptions Count="3"> 620 634 <Item1>
Note:
See TracChangeset
for help on using the changeset viewer.