Changeset 31


Ignore:
Timestamp:
Nov 11, 2009, 1:43:47 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Chyby v inicializaci objektů.
Location:
branches/Analyzátor gramatiky
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/Analyzátor gramatiky/PascalCompiler.lpi

    r30 r31  
    3131      </Item1>
    3232    </RequiredPackages>
    33     <Units Count="6">
     33    <Units Count="7">
    3434      <Unit0>
    3535        <Filename Value="PascalCompiler.lpr"/>
    3636        <IsPartOfProject Value="True"/>
    37         <CursorPos X="11" Y="12"/>
     37        <CursorPos X="28" Y="8"/>
    3838        <TopLine Value="1"/>
    3939        <EditorIndex Value="1"/>
    40         <UsageCount Value="25"/>
     40        <UsageCount Value="27"/>
    4141        <Loaded Value="True"/>
    4242      </Unit0>
     
    4848        <ResourceBaseClass Value="Form"/>
    4949        <UnitName Value="UMainForm"/>
    50         <CursorPos X="23" Y="58"/>
     50        <CursorPos X="20" Y="58"/>
    5151        <TopLine Value="54"/>
    5252        <EditorIndex Value="2"/>
    53         <UsageCount Value="25"/>
     53        <UsageCount Value="27"/>
    5454        <Loaded Value="True"/>
    5555      </Unit1>
     
    5858        <IsPartOfProject Value="True"/>
    5959        <UnitName Value="UGrammer"/>
    60         <CursorPos X="1" Y="322"/>
    61         <TopLine Value="307"/>
     60        <CursorPos X="10" Y="398"/>
     61        <TopLine Value="384"/>
    6262        <EditorIndex Value="0"/>
    63         <UsageCount Value="25"/>
     63        <UsageCount Value="27"/>
    6464        <Loaded Value="True"/>
    6565      </Unit2>
     
    7171        <TopLine Value="86"/>
    7272        <EditorIndex Value="3"/>
    73         <UsageCount Value="25"/>
     73        <UsageCount Value="27"/>
    7474        <Loaded Value="True"/>
    7575      </Unit3>
     
    8383        <Filename Value="..\..\..\..\..\Programy\Lazarus_0.9.29\fpc\2.3.1\source\rtl\objpas\fgl.pp"/>
    8484        <UnitName Value="fgl"/>
    85         <CursorPos X="3" Y="707"/>
    86         <TopLine Value="705"/>
     85        <CursorPos X="6" Y="730"/>
     86        <TopLine Value="725"/>
    8787        <UsageCount Value="11"/>
    8888      </Unit5>
     89      <Unit6>
     90        <Filename Value="..\..\..\..\..\Programy\Lazarus_0.9.29\fpc\2.3.1\source\rtl\inc\objpash.inc"/>
     91        <CursorPos X="23" Y="175"/>
     92        <TopLine Value="160"/>
     93        <UsageCount Value="10"/>
     94      </Unit6>
    8995    </Units>
    9096    <JumpHistory Count="30" HistoryIndex="29">
    9197      <Position1>
    92         <Filename Value="UProgram.pas"/>
    93         <Caret Line="105" Column="1" TopLine="90"/>
     98        <Filename Value="PascalCompiler.lpr"/>
     99        <Caret Line="12" Column="11" TopLine="1"/>
    94100      </Position1>
    95101      <Position2>
    96         <Filename Value="UProgram.pas"/>
    97         <Caret Line="106" Column="1" TopLine="91"/>
     102        <Filename Value="PascalCompiler.lpr"/>
     103        <Caret Line="18" Column="15" TopLine="1"/>
    98104      </Position2>
    99105      <Position3>
    100106        <Filename Value="UProgram.pas"/>
    101         <Caret Line="107" Column="1" TopLine="92"/>
     107        <Caret Line="19" Column="20" TopLine="1"/>
    102108      </Position3>
    103109      <Position4>
    104         <Filename Value="UProgram.pas"/>
    105         <Caret Line="108" Column="1" TopLine="93"/>
     110        <Filename Value="UMainForm.pas"/>
     111        <Caret Line="83" Column="15" TopLine="57"/>
    106112      </Position4>
    107113      <Position5>
    108         <Filename Value="UProgram.pas"/>
    109         <Caret Line="111" Column="1" TopLine="96"/>
     114        <Filename Value="UMainForm.pas"/>
     115        <Caret Line="642" Column="15" TopLine="621"/>
    110116      </Position5>
    111117      <Position6>
    112         <Filename Value="UProgram.pas"/>
    113         <Caret Line="113" Column="1" TopLine="98"/>
     118        <Filename Value="UMainForm.pas"/>
     119        <Caret Line="629" Column="55" TopLine="589"/>
    114120      </Position6>
    115121      <Position7>
    116         <Filename Value="UProgram.pas"/>
    117         <Caret Line="115" Column="1" TopLine="100"/>
     122        <Filename Value="UMainForm.pas"/>
     123        <Caret Line="58" Column="20" TopLine="54"/>
    118124      </Position7>
    119125      <Position8>
    120126        <Filename Value="UProgram.pas"/>
    121         <Caret Line="116" Column="1" TopLine="101"/>
     127        <Caret Line="116" Column="21" TopLine="93"/>
    122128      </Position8>
    123129      <Position9>
    124130        <Filename Value="UProgram.pas"/>
    125         <Caret Line="117" Column="1" TopLine="102"/>
     131        <Caret Line="118" Column="22" TopLine="102"/>
    126132      </Position9>
    127133      <Position10>
    128134        <Filename Value="UGrammer.pas"/>
    129         <Caret Line="322" Column="1" TopLine="307"/>
     135        <Caret Line="238" Column="10" TopLine="233"/>
    130136      </Position10>
    131137      <Position11>
    132138        <Filename Value="UGrammer.pas"/>
    133         <Caret Line="323" Column="22" TopLine="309"/>
     139        <Caret Line="93" Column="22" TopLine="78"/>
    134140      </Position11>
    135141      <Position12>
    136142        <Filename Value="UGrammer.pas"/>
    137         <Caret Line="324" Column="6" TopLine="311"/>
     143        <Caret Line="89" Column="57" TopLine="74"/>
    138144      </Position12>
    139145      <Position13>
    140         <Filename Value="UGrammer.pas"/>
    141         <Caret Line="25" Column="12" TopLine="10"/>
     146        <Filename Value="UProgram.pas"/>
     147        <Caret Line="119" Column="31" TopLine="96"/>
    142148      </Position13>
    143149      <Position14>
    144150        <Filename Value="UGrammer.pas"/>
    145         <Caret Line="328" Column="32" TopLine="311"/>
     151        <Caret Line="102" Column="63" TopLine="88"/>
    146152      </Position14>
    147153      <Position15>
     
    151157      <Position16>
    152158        <Filename Value="UGrammer.pas"/>
    153         <Caret Line="322" Column="1" TopLine="307"/>
     159        <Caret Line="309" Column="36" TopLine="286"/>
    154160      </Position16>
    155161      <Position17>
    156162        <Filename Value="UGrammer.pas"/>
    157         <Caret Line="324" Column="1" TopLine="309"/>
     163        <Caret Line="25" Column="23" TopLine="10"/>
    158164      </Position17>
    159165      <Position18>
    160166        <Filename Value="UGrammer.pas"/>
    161         <Caret Line="325" Column="1" TopLine="310"/>
     167        <Caret Line="22" Column="45" TopLine="7"/>
    162168      </Position18>
    163169      <Position19>
    164170        <Filename Value="UGrammer.pas"/>
    165         <Caret Line="326" Column="1" TopLine="311"/>
     171        <Caret Line="309" Column="48" TopLine="371"/>
    166172      </Position19>
    167173      <Position20>
    168         <Filename Value="UGrammer.pas"/>
    169         <Caret Line="327" Column="1" TopLine="312"/>
     174        <Filename Value="UProgram.pas"/>
     175        <Caret Line="101" Column="1" TopLine="86"/>
    170176      </Position20>
    171177      <Position21>
    172178        <Filename Value="UGrammer.pas"/>
    173         <Caret Line="329" Column="1" TopLine="314"/>
     179        <Caret Line="327" Column="36" TopLine="305"/>
    174180      </Position21>
    175181      <Position22>
    176         <Filename Value="UGrammer.pas"/>
    177         <Caret Line="203" Column="1" TopLine="188"/>
     182        <Filename Value="UProgram.pas"/>
     183        <Caret Line="101" Column="1" TopLine="86"/>
    178184      </Position22>
    179185      <Position23>
    180186        <Filename Value="UGrammer.pas"/>
    181         <Caret Line="214" Column="1" TopLine="199"/>
     187        <Caret Line="320" Column="1" TopLine="305"/>
    182188      </Position23>
    183189      <Position24>
    184         <Filename Value="UGrammer.pas"/>
    185         <Caret Line="215" Column="1" TopLine="200"/>
     190        <Filename Value="UProgram.pas"/>
     191        <Caret Line="101" Column="1" TopLine="86"/>
    186192      </Position24>
    187193      <Position25>
    188194        <Filename Value="UGrammer.pas"/>
    189         <Caret Line="322" Column="1" TopLine="307"/>
     195        <Caret Line="316" Column="11" TopLine="310"/>
    190196      </Position25>
    191197      <Position26>
    192198        <Filename Value="UGrammer.pas"/>
    193         <Caret Line="324" Column="1" TopLine="309"/>
     199        <Caret Line="292" Column="22" TopLine="277"/>
    194200      </Position26>
    195201      <Position27>
    196202        <Filename Value="UGrammer.pas"/>
    197         <Caret Line="325" Column="1" TopLine="310"/>
     203        <Caret Line="43" Column="26" TopLine="28"/>
    198204      </Position27>
    199205      <Position28>
    200206        <Filename Value="UGrammer.pas"/>
    201         <Caret Line="326" Column="1" TopLine="311"/>
     207        <Caret Line="38" Column="62" TopLine="23"/>
    202208      </Position28>
    203209      <Position29>
    204210        <Filename Value="UGrammer.pas"/>
    205         <Caret Line="327" Column="1" TopLine="312"/>
     211        <Caret Line="290" Column="39" TopLine="283"/>
    206212      </Position29>
    207213      <Position30>
    208214        <Filename Value="UGrammer.pas"/>
    209         <Caret Line="326" Column="1" TopLine="311"/>
     215        <Caret Line="38" Column="17" TopLine="17"/>
    210216      </Position30>
    211217    </JumpHistory>
     
    231237  </CompilerOptions>
    232238  <Debugging>
    233     <BreakPoints Count="2">
     239    <BreakPoints Count="3">
    234240      <Item1>
    235241        <Source Value="UMainForm.pas"/>
     
    240246        <Line Value="101"/>
    241247      </Item2>
     248      <Item3>
     249        <Source Value="UGrammer.pas"/>
     250        <Line Value="323"/>
     251      </Item3>
    242252    </BreakPoints>
    243253    <Exceptions Count="3">
  • branches/Analyzátor gramatiky/UGrammer.pas

    r30 r31  
    3030  end;
    3131
     32  { TPossibleCharacter }
     33
    3234  TPossibleCharacter = class
    3335    Character: Char;
    3436    RulePath: TGrammerPath;
    3537    procedure Assign(Source: TPossibleCharacter);
     38    constructor Create;
     39    destructor Destroy; override;
    3640  end;
    3741
     
    138142  I: Integer;
    139143begin
    140   for I := 1 to Length(Text) do AddTerminal(Text[I], False, False);
     144  for I := 1 to Length(Text) do
     145    AddTerminal(Text[I], False, False);
    141146end;
    142147
     
    146151begin
    147152  for I := 0 to Items.Count - 1 do
    148   with Items[I] do begin
    149     Processed := False;
    150   end;
     153    Items[I].Processed := False;
    151154end;
    152155
     
    183186      if UseIndex > 0 then begin
    184187        // Forward generation to upper item
    185        with Path.Items[Path.Items.Add(TPathItem.Create)] do begin
     188        Path.Items.Delete(Path.Items.Count - 1);
     189        with Path.Items[Path.Items.Count - 1] do begin
    186190          NextItemIndex := ItemIndex;
    187191          NextCharIndex := CharIndex;
     
    237241begin
    238242  for I := 0 to Rules.Count - 1 do
    239   with Rules[I] do begin
    240     ClearProcessed;
    241   end;
     243    Rules[I].ClearProcessed;
    242244end;
    243245
     
    250252  for I := 0 to Rules.Count - 1 do with Rules[I] do begin
    251253    for II := 0 to Items.Count - 1 do with Items[II] do begin
    252       if (ItemType = itNonterminal) and (Rule = nil) then begin
     254      if (ItemType = itNonterminal) and (not Assigned(Rule)) then begin
    253255        J := 0;
    254         while (J < Rules.Count) and (Rules[J].Name <> RuleName)  do Inc(J);
     256        while (J < Rules.Count) and (Rules[J].Name <> RuleName) do Inc(J);
    255257        if J < Rules.Count then Rule := Rules[J] else
    256258          raise Exception.Create('Rule link correction failed on rule ' +
     
    309311          NextRule := Rule;
    310312        end;
    311         Path.Items.Count := Path.Items.Count - 1;
     313        Path.Items.Delete(Path.Items.Count - 1);
    312314        NextRule.GetPossibleCharacters(Path, Characters, NextItemIndex + 1, NextCharIndex);
    313315  end;
     
    380382end;
    381383
     384constructor TPossibleCharacter.Create;
     385begin
     386  RulePath := TGrammerPath.Create;
     387end;
     388
     389destructor TPossibleCharacter.Destroy;
     390begin
     391  RulePath.Destroy;
     392  inherited Destroy;
     393end;
     394
    382395{ TPossibleCharacters }
    383396
  • branches/Analyzátor gramatiky/UMainForm.lrs

    r29 r31  
     1{ Toto je automaticky generovanÃœ zdrojovÃœ soubor lazarusu }
     2
    13LazarusResources.Add('TMainForm','FORMDATA',[
    24  'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3#1#1#6'Height'#3#141#2#3'Top'#2#0#5
  • branches/Analyzátor gramatiky/UMainForm.pas

    r29 r31  
    627627      if Assigned(SourceProgram.Items[I]) then
    628628      //TreeView1.Items.AddChild(TreeNode, IntToStr(I))
    629       ShowProgramNode(TreeNode, TProgramItem(SourceProgram.Items[I]))
     629      ShowProgramNode(TreeNode, SourceProgram.Items[I])
    630630      else TreeView1.Items.AddChild(TreeNode, 'x');
    631631  end else begin
  • branches/Analyzátor gramatiky/UProgram.pas

    r30 r31  
    7272        if not Assigned(SelectedProgramItem.Items[CharIndex]) then
    7373          SelectedProgramItem.Items[CharIndex] := TProgramItem.Create;
    74         SelectedProgramItem := TProgramItem(SelectedProgramItem.Items[CharIndex]);
     74        SelectedProgramItem := SelectedProgramItem.Items[CharIndex];
    7575(*      end else begin
    7676        SelectedProgramItem.Items.Count := SelectedProgramItem.Items.Count + 1;
     
    109109  end;
    110110
    111   for I := 1 to Length(Text) do
    112   begin
    113     if (Text[I] <> #13) and (Text[I] <> #10) then
    114     begin
     111  for I := 1 to Length(Text) do begin
     112    if (Text[I] <> #13) and (Text[I] <> #10) then begin
    115113      UseIndex := Path.Items[Path.Items.Count - 1].ItemIndex;
    116114      UseCharIndex := Path.Items[Path.Items.Count - 1].CharIndex;
     
    208206  I: Integer;
    209207begin
    210   for I := 0 to Items.Count - 1 do with Items[I] do begin
     208  for I := 0 to Items.Count - 1 do
     209  with Items[I] do begin
    211210    if ItemType = itNonterminal then begin
    212211      if Rule.Name = ARule.Name then begin
     
    235234begin
    236235  for I := 0 to Items.Count - 1 do
    237   with TProgramItem(Items[I]) do begin
     236  with Items[I] do begin
    238237    if ItemType = itNonterminal then Delete;
    239238  end;
     
    246245  I := 0;
    247246  while I < Items.Count do
    248   with TProgramItem(Items[I]) do begin
     247  with Items[I] do begin
    249248    if ItemType = itNonterminal then begin
    250249      if Items.Count = 0 then begin
     
    260259procedure TProgramItem.DeleteItem(Index: Integer);
    261260begin
    262   if TProgramItem(Items[Index]).ItemType = itNonterminal then
    263     TProgramItem(Items[Index]).Delete;
     261  if Items[Index].ItemType = itNonterminal then
     262    Items[Index].Delete;
    264263  Items.Delete(Index);
    265264end;
     
    314313begin
    315314  Result := '';
    316   for I := 0 to Items.Count - 1 do with Items[I] do begin
     315  for I := 0 to Items.Count - 1 do
     316  with Items[I] do begin
    317317    if ItemType = itTerminal then Result := Result + Value
    318318      else Result := Result + MergeToTerminal;
Note: See TracChangeset for help on using the changeset viewer.