Changeset 9 for UGrammer.pas
- Timestamp:
- Oct 16, 2007, 9:16:28 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
UGrammer.pas
r8 r9 295 295 Path: TGrammerPath; 296 296 I, II: Integer; 297 Q: Integer; 297 298 C: Integer; 298 299 Scope: TPossibleCharacters; … … 301 302 UseRule: TGrammerRule; 302 303 ExpectedCharacters: string; 303 Level: Integer; 304 Level: array of Integer; 305 LevelLength: Integer; 306 LevelIsLeft: Boolean; 304 307 begin 305 308 SetLength(Path.Items, Length(Path.Items) + 1); … … 320 323 UseRule.GetPossibleCharacters(Path, Scope, UseIndex, UseCharIndex); 321 324 C := Length(Scope.Items); 322 Level := 0; //High(Integer); 323 for II := High(Scope.Items) downto 0 do begin 324 if (Scope.Items[II].Character = Text[I]) and (Level < Length(Scope.Items[II].RulePath.Items)) 325 then begin 326 C := II; 327 Level := Length(Scope.Items[II].RulePath.Items); 328 end; 329 end; 325 326 SetLength(Level, 0); 327 for II := 0 to High(Scope.Items) do with Scope.Items[II] do begin 328 if (Character = Text[I]) then begin 329 if Length(RulePath.Items) > Length(Level) then begin 330 LevelLength := Length(Level); 331 SetLength(Level, Length(RulePath.Items)); 332 for Q := LevelLength to High(Level) do 333 Level[Q] := High(Integer); 334 end; 335 LevelIsLeft := True; 336 for Q := 0 to High(Level) do begin 337 if Level[Q] > RulePath.Items[Q].ItemIndex then begin 338 LevelIsLeft := False; 339 Break; 340 end; 341 if Level[Q] < RulePath.Items[Q].ItemIndex then Break; 342 end; 343 if (not LevelIsLeft) or (Length(RulePath.Items) > Length(Level)) then begin 344 SetLength(Level, Length(RulePath.Items)); 345 for Q := 0 to High(Level) do 346 Level[Q] := RulePath.Items[Q].ItemIndex; 347 C := II; 348 end; 349 end; 350 end; 351 330 352 if C < Length(Scope.Items) then begin 331 353 Path.Assign(Scope.Items[C].RulePath); … … 343 365 ExpectedCharacters := ExpectedCharacters + Scope.Items[II].Character; 344 366 //raise Exception.Create('Parse error. Expected "' + ExpectedCharacters + '" but found "' + Text[I] + '".'); 345 MainForm. Label1.Caption:= 'Parse error. Expected "' + ExpectedCharacters + '" but found "' + Text[I] + '".';367 MainForm.StatusBar1.SimpleText := 'Parse error. Expected "' + ExpectedCharacters + '" but found "' + Text[I] + '".'; 346 368 break; 347 369 end;
Note:
See TracChangeset
for help on using the changeset viewer.