Changeset 73 for branches/Transpascal/Compiler/Analyze/UPascalParser.pas
- Timestamp:
- Oct 20, 2010, 11:16:02 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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(':=');
Note:
See TracChangeset
for help on using the changeset viewer.