Changeset 5 for UMainForm.pas
- Timestamp:
- Oct 4, 2007, 3:53:57 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
UMainForm.pas
r3 r5 6 6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 7 Dialogs, StdCtrls, ComCtrls; 8 9 const 10 DefaultGrammerFileName: string = 'grammer/test.grm'; 8 11 9 12 type … … 203 206 AddRule(Digit, False, False); 204 207 AddRule(AlphabeticCharacter, False, False); 208 AddTerminal('_', False, False); 205 209 end; 206 210 Rules.Add(AlphaNumericCharacter); … … 235 239 236 240 Concatenation := TGrammerRule.Create; 241 Separation := TGrammerRule.Create; 237 242 238 243 OptionBlock := TGrammerRule.Create; … … 242 247 AddTerminal('[', False, False); 243 248 AddRule(WhiteSpace, True, True); 244 AddRule( Concatenation, False, False);249 AddRule(Separation, False, False); 245 250 AddRule(WhiteSpace, True, True); 246 251 AddTerminal(']', False, False); … … 254 259 AddTerminal('{', False, False); 255 260 AddRule(WhiteSpace, True, True); 256 AddRule( Concatenation, False, False);261 AddRule(Separation, False, False); 257 262 AddRule(WhiteSpace, True, True); 258 263 AddTerminal('}', False, False); … … 266 271 AddTerminal('(', False, False); 267 272 AddRule(WhiteSpace, True, True); 268 AddRule( Concatenation, False, False);273 AddRule(Separation, False, False); 269 274 AddRule(WhiteSpace, True, True); 270 275 AddTerminal(')', False, False); … … 297 302 RuleType := rtSequence; 298 303 AddRule(WhiteSpace, False, True); 299 AddRule(Expression, False, False);304 AddRule(Expression, True, False); 300 305 end; 301 306 Rules.Add(ConcatenationBlock); … … 320 325 Rules.Add(SeparationBlock); 321 326 322 Separation := TGrammerRule.Create;323 327 with Separation do begin 324 328 Name := 'Separation'; … … 359 363 360 364 SourceProgram := TProgram.Create; 361 Memo1.Lines.LoadFromFile( 'P0.grm');365 Memo1.Lines.LoadFromFile(DefaultGrammerFileName); 362 366 SourceCode := '';; 363 367 // with Memo1.Lines do … … 483 487 procedure TMainForm.FormDestroy(Sender: TObject); 484 488 begin 485 Memo1.Lines.SaveToFile( 'Program.pas');489 Memo1.Lines.SaveToFile(DefaultGrammerFileName); 486 490 487 491 Grammer.Free; … … 588 592 UseRule: TGrammerRule; 589 593 ExpectedCharacters: string; 594 Level: Integer; 590 595 begin 591 596 SetLength(Path.Items, Length(Path.Items) + 1); … … 605 610 ClearProcessed; 606 611 UseRule.GetPossibleCharacters(Path, Scope, UseIndex, UseCharIndex); 607 C := 0; 608 while (C < Length(Scope.Items)) and 609 (Scope.Items[C].Character <> Text[I]) do Inc(C); 612 C := Length(Scope.Items); 613 Level := 0; //High(Integer); 614 for II := High(Scope.Items) downto 0 do begin 615 if (Scope.Items[II].Character = Text[I]) and (Level < Length(Scope.Items[II].RulePath.Items)) 616 then begin 617 C := II; 618 Level := Length(Scope.Items[II].RulePath.Items); 619 end; 620 end; 610 621 if C < Length(Scope.Items) then begin 611 622 Path.Assign(Scope.Items[C].RulePath);
Note:
See TracChangeset
for help on using the changeset viewer.