Changeset 39 for branches/DelphiToC/Analyze/UPascalParser.pas
- Timestamp:
- Aug 5, 2010, 9:51:16 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Analyze/UPascalParser.pas
r38 r39 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls,UPascalSource, FileUtil;9 Dialogs, UPascalSource, FileUtil; 10 10 11 11 type … … 254 254 with Parser do begin 255 255 Expect('while'); 256 Condition.CommonBlock := CommonBlock; 256 257 TParserExpression(Condition).Parse(Parser); 257 258 Expect('do'); … … 282 283 if Identifier = '(' then begin 283 284 // Subexpression 284 with TExpression(Expressions [Expressions.Count - 1]) do begin285 with TExpression(Expressions.Last) do begin 285 286 SubItems[1] := TExpression.Create; 286 287 TParserExpression(SubItems[1]).Parse(Parser); 287 288 end; 288 289 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 290 CommonBlock := Self.CommonBlock; 289 291 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 290 292 end; … … 293 295 if IsOperator(Identifier) then begin 294 296 // Operator 295 TExpression(Expressions [Expressions.Count - 1]).OperatorName := Identifier;296 TExpression(Expressions [Expressions.Count - 1]).NodeType := ntOperator;297 TExpression(Expressions.Last).OperatorName := Identifier; 298 TExpression(Expressions.Last).NodeType := ntOperator; 297 299 end else 298 300 if IsIdentificator(Identifier) then begin … … 301 303 if Assigned(NewVariable) then begin 302 304 // Referenced variable 303 with TExpression(Expressions [Expressions.Count - 1]) do begin305 with TExpression(Expressions.Last) do begin 304 306 SubItems[1] := TExpression.Create; 305 307 TExpression(SubItems[1]).NodeType := ntVariable; … … 307 309 end; 308 310 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 311 CommonBlock := Self.CommonBlock; 309 312 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 310 313 end; … … 313 316 if Assigned(Method) then begin 314 317 // Referenced method 315 with TExpression(Expressions [Expressions.Count - 1]) do begin318 with TExpression(Expressions.Last) do begin 316 319 SubItems[1] := TExpression.Create; 317 320 if NextCode = '(' then // Method with parameters … … 331 334 Expect(')'); 332 335 end; 333 TExpression(SubItems[1]).NodeType := n TFunction;336 TExpression(SubItems[1]).NodeType := ntFunction; 334 337 TExpression(SubItems[1]).Method := Method; 335 338 end; 336 339 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 340 CommonBlock := Self.CommonBlock; 337 341 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 338 342 end; … … 341 345 if Assigned(Constant) then begin 342 346 // Referenced constant 343 with TExpression(Expressions [Expressions.Count - 1]) do begin347 with TExpression(Expressions.Last) do begin 344 348 SubItems[1] := TExpression.Create; 345 349 TExpression(SubItems[1]).NodeType := ntConstant; … … 347 351 end; 348 352 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 353 CommonBlock := Self.CommonBlock; 349 354 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 350 355 end; … … 357 362 begin 358 363 // Constant value 359 with TExpression(Expressions [Expressions.Count - 1]) do begin364 with TExpression(Expressions.Last) do begin 360 365 SubItems[1] := TExpression.Create; 366 TExpression(SubItems[1]).CommonBlock := Self.CommonBlock; 361 367 TExpression(SubItems[1]).NodeType := ntConstant; 362 368 … … 367 373 // TExpression(SubItems[1]).Value[I - 1] := Byte(Identifier[I]); 368 374 end else begin 369 //SetLength(TExpression(SubItems[1]).Value, 1); 370 //TExpression(SubItems[1]).Value[0] := StrToInt(Identifier); 375 TExpression(SubItems[1]).Value := Identifier; 371 376 end; 372 377 end; 378 //ShowMessage(IntToStr(Expressions.Count)); 373 379 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 380 CommonBlock := Self.CommonBlock; 374 381 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 375 382 end; … … 386 393 TExpression(Expressions[I - 1]).SubItems[1] := Expressions[I]; 387 394 TExpression(Expressions[I + 1]).SubItems[0] := Expressions[I]; 388 Expressions.Delete(I);395 //Expressions.Delete(I); 389 396 end else Inc(I); 390 397 end; 391 398 end; 392 399 end; 393 Result := TExpression(TExpression(Expressions[0]).SubItems[1]); 394 TExpression(Expressions[0]).SubItems[1] := nil; 400 Assign(TExpression(TExpression(Expressions.First).SubItems[1])); 401 TExpression(Expressions.First).SubItems[1] := nil; 402 //ShowMessage(IntToStr(Expressions.Count)); 395 403 TExpression(Expressions[1]).SubItems[0] := nil; 396 404 Expressions.Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.