Changeset 14 for branches/DelphiToC/UPascalParser.pas
- Timestamp:
- Apr 9, 2009, 11:04:41 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/UPascalParser.pas
r13 r14 12 12 TPascalParser = class 13 13 private 14 CodePosition: Integer;15 14 ProgramCode: TProgram; 16 15 FOnErrorMessage: TOnErrorMessage; 17 16 procedure ErrorMessage(Text: string); 18 17 public 18 CodePosition: Integer; 19 19 SourceCode: TStringList; 20 20 function IsAlphanumeric(Character: Char): Boolean; … … 32 32 procedure ParseModuleUnit(Module: TModule); 33 33 procedure ParseModuleProgram(Module: TModule); 34 35 34 procedure ParseFunction(AFunction: TFunction); 36 35 procedure ParseVariableList(VariableList: TVariableList); … … 207 206 begin 208 207 with AProgram do begin 209 for I := 0 to Modules.Count - 1 do210 TModule(Modules[I]).Clear;211 Modules.Clear;212 with TModule(Modules[Modules.Add(TModule.Create)]) do begin213 Name := 'main';214 with TType(Types[Types.Add(TType.Create)]) do begin215 Name := 'byte';216 Size := 1;217 UsedType := nil;218 end;219 end;208 for I := 0 to Modules.Count - 1 do 209 TModule(Modules[I]).Clear; 210 Modules.Clear; 211 with TModule(Modules[Modules.Add(TModule.Create)]) do begin 212 Name := 'main'; 213 with TType(Types[Types.Add(TType.Create)]) do begin 214 Name := 'byte'; 215 Size := 1; 216 UsedType := nil; 217 end; 218 end; 220 219 ParseModule(TModule(Modules[0])); 221 220 end; … … 294 293 Constant: TConstant; 295 294 // Brackets: Integer; 296 Expressions: T List; // TList<TExpression>;295 Expressions: TExpressionList; 297 296 I: Integer; 298 297 II: Integer; 299 298 begin 300 Expressions := T List.Create;299 Expressions := TExpressionList.Create; 301 300 Expressions.Add(TExpression.Create); 302 301 with CommonBlock do begin … … 367 366 end else 368 367 begin 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 368 with TExpression(Expressions[Expressions.Count - 1]) do begin 369 SubItems[1] := TExpression.Create; 370 TExpression(SubItems[1]).NodeType := ntConstant; 371 372 if Identifier[1] = '''' then begin 373 SetLength(TExpression(SubItems[1]).Value, Length(Identifier)); 374 for I := 1 to Length(Identifier) do TExpression(SubItems[1]).Value[I - 1] := Byte(Identifier[I]); 375 end else begin 376 SetLength(TExpression(SubItems[1]).Value, 1); 377 TExpression(SubItems[1]).Value[0] := StrToInt(Identifier); 378 end; 379 end; 380 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 381 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 382 end; 384 383 end; 385 384 end; … … 400 399 end; 401 400 Result := TExpression(Expressions[0]).SubItems[1]; 402 TExpression(Expressions[0]). Destroy;403 TExpression(Expressions[1]). Destroy;401 TExpression(Expressions[0]).SubItems[1] := nil; 402 TExpression(Expressions[1]).SubItems[0] := nil; 404 403 Expressions.Destroy; 405 404 end; … … 623 622 end; 624 623 625 626 627 628 629 630 631 624 end.
Note:
See TracChangeset
for help on using the changeset viewer.