Changeset 30 for branches/Analyzátor gramatiky/UProgram.pas
- Timestamp:
- Nov 11, 2009, 12:56:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Analyzátor gramatiky/UProgram.pas
r29 r30 6 6 7 7 uses 8 Classes, ComCtrls, SysUtils, Math,UGrammer, fgl;8 Classes, ComCtrls, SysUtils, UGrammer, fgl; 9 9 10 10 type … … 62 62 begin 63 63 SelectedProgramItem := TopItem; 64 for I := 0 to High(Path.Items) do with Path.Items[I] do begin 64 for I := 0 to Path.Items.Count - 1 do 65 with Path.Items[I] do begin 65 66 SelectedProgramItem.ItemType := itNonterminal; 66 67 if not Assigned(SelectedProgramItem.Rule) then SelectedProgramItem.Rule := Rule; … … 99 100 Level: array of Integer; 100 101 begin 101 SetLength(Path.Items, Length(Path.Items) + 1); 102 with Path.Items[High(Path.Items)] do begin 102 Path := TGrammerPath.Create; 103 Scope := TPossibleCharacters.Create; 104 105 with Path.Items[Path.Items.Add(TPathItem.Create)] do begin 103 106 Rule := Grammer.TopRule; 104 107 ItemIndex := 0; … … 110 113 if (Text[I] <> #13) and (Text[I] <> #10) then 111 114 begin 112 UseIndex := Path.Items[ High(Path.Items)].ItemIndex;113 UseCharIndex := Path.Items[ High(Path.Items)].CharIndex;114 UseRule := Path.Items[ High(Path.Items)].Rule;115 SetLength(Path.Items, Length(Path.Items)- 1);116 S etLength(Scope.Items, 0);115 UseIndex := Path.Items[Path.Items.Count - 1].ItemIndex; 116 UseCharIndex := Path.Items[Path.Items.Count - 1].CharIndex; 117 UseRule := Path.Items[Path.Items.Count - 1].Rule; 118 Path.Items.Delete(Path.Items.Count - 1); 119 Scope.Items.Clear; 117 120 Grammer.ClearProcessed; 118 121 UseRule.GetPossibleCharacters(Path, Scope, UseIndex, UseCharIndex); 119 C := Length(Scope.Items);122 C := Scope.Items.Count; 120 123 121 124 // Possible character selection 122 125 SetLength(Level, 0); 123 for II := 0 to High(Scope.Items) do with Scope.Items[II] do 126 for II := 0 to Scope.Items.Count - 1 do 127 with Scope.Items[II] do 124 128 begin 125 129 if (Character = Text[I]) then … … 174 178 end; 175 179 176 if C < Length(Scope.Items)then begin180 if C < Scope.Items.Count then begin 177 181 Path.Assign(Scope.Items[C].RulePath); 178 for II := 0 to Length(Path.Items) - 1 do with Path.Items[II] do begin 182 for II := 0 to Path.Items.Count - 1 do 183 with Path.Items[II] do begin 179 184 if Affected then Inc(CharIndex); 180 185 end; 181 186 Insert(Path, Scope.Items[C].Character); 182 for II := 0 to Length(Path.Items) - 1 do with Path.Items[II] do begin 187 for II := 0 to Path.Items.Count - 1 do 188 with Path.Items[II] do begin 183 189 Affected := False; 184 190 end; … … 186 192 end else begin 187 193 ExpectedCharacters := ''; 188 for II := 0 to Length(Scope.Items)- 1 do194 for II := 0 to Scope.Items.Count - 1 do 189 195 ExpectedCharacters := ExpectedCharacters + Scope.Items[II].Character; 190 196 //raise Exception.Create('Parse error. Expected "' + ExpectedCharacters + '" but found "' + Text[I] + '".'); … … 194 200 end; 195 201 end; 202 Path.Destroy; 203 Scope.Destroy; 196 204 end; 197 205
Note:
See TracChangeset
for help on using the changeset viewer.