Changeset 211 for branches/interpreter2/UParser.pas
- Timestamp:
- Apr 22, 2020, 9:00:02 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/UParser.pas
r207 r211 63 63 while not Tokenizer.CheckNext('end', tkKeyword) do begin 64 64 if ParseCommand(Block, Command) then begin 65 Command.Parent := BeginEnd; 65 66 BeginEnd.Commands.Add(Command); 66 67 Tokenizer.Expect(';', tkSpecialSymbol); … … 185 186 Prog.Block.Free; 186 187 Prog.Block := Block; 188 Block.Parent := Prog; 187 189 Tokenizer.Expect('.', tkSpecialSymbol); 188 190 end else begin … … 198 200 Result := False; 199 201 Block := TBlock.Create; 200 Block.Parent := ParentBlock;202 Block.ParentBlock := ParentBlock; 201 203 ParseBlockVar(Block); 202 204 ParseBlockConst(Block); … … 205 207 Block.BeginEnd.Free; 206 208 Block.BeginEnd := BeginEnd; 209 BeginEnd.Parent := Block; 207 210 end else Block.Free; 208 211 end; … … 293 296 Variable: TVariable; 294 297 Expression: TExpression; 295 begin 298 LastPos: TTokenizerPos; 299 begin 300 LastPos := Tokenizer.Pos; 296 301 Result := False; 297 302 Token := Tokenizer.GetNext; 298 303 if Token.Kind = tkIdentifier then begin 299 Result := True;300 304 Variable := Block.GetVariable(Token.Text); 301 305 if Assigned(Variable) then begin … … 308 312 Assignment.Expression.Free; 309 313 Assignment.Expression := Expression; 314 Expression.Parent := Assignment; 310 315 end else begin 311 316 Result := False; … … 316 321 end else Error('Variable ' + Token.Text + ' not defined.'); 317 322 end; 323 if not Result then Tokenizer.Pos := LastPos; 318 324 end; 319 325 … … 481 487 IfThenElse.CommandThen.Free; 482 488 IfThenElse.CommandThen := Command; 489 Command.Parent := IfThenElse; 483 490 if Tokenizer.CheckNext('else', tkKeyword) then begin 484 491 Tokenizer.Expect('else', tkKeyword); … … 486 493 IfThenElse.CommandElse.Free; 487 494 IfThenElse.CommandElse := Command; 495 Command.Parent := IfThenElse; 488 496 end else Error('Expected command'); 489 497 end; … … 510 518 WhileDo.Command.Free; 511 519 WhileDo.Command := Command; 520 Command.Parent := WhileDo; 512 521 end else Error('Expected command'); 513 522 end else Error('Expected expression'); … … 529 538 if ParseCommand(Block, Command) then begin 530 539 RepeatUntil.Commands.Add(Command); 540 Command.Parent := RepeatUntil; 531 541 Tokenizer.Expect(';', tkSpecialSymbol); 532 542 end else begin … … 569 579 ForToDo.Command.Free; 570 580 ForToDo.Command := Command; 581 Command.Parent := ForToDo; 571 582 end else Error('Expected command.'); 572 583 end else Error('Expected expression.');
Note:
See TracChangeset
for help on using the changeset viewer.