Changeset 31 for branches/Analyzátor gramatiky
- Timestamp:
- Nov 11, 2009, 1:43:47 PM (15 years ago)
- Location:
- branches/Analyzátor gramatiky
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Analyzátor gramatiky/PascalCompiler.lpi
r30 r31 31 31 </Item1> 32 32 </RequiredPackages> 33 <Units Count=" 6">33 <Units Count="7"> 34 34 <Unit0> 35 35 <Filename Value="PascalCompiler.lpr"/> 36 36 <IsPartOfProject Value="True"/> 37 <CursorPos X=" 11" Y="12"/>37 <CursorPos X="28" Y="8"/> 38 38 <TopLine Value="1"/> 39 39 <EditorIndex Value="1"/> 40 <UsageCount Value="2 5"/>40 <UsageCount Value="27"/> 41 41 <Loaded Value="True"/> 42 42 </Unit0> … … 48 48 <ResourceBaseClass Value="Form"/> 49 49 <UnitName Value="UMainForm"/> 50 <CursorPos X="2 3" Y="58"/>50 <CursorPos X="20" Y="58"/> 51 51 <TopLine Value="54"/> 52 52 <EditorIndex Value="2"/> 53 <UsageCount Value="2 5"/>53 <UsageCount Value="27"/> 54 54 <Loaded Value="True"/> 55 55 </Unit1> … … 58 58 <IsPartOfProject Value="True"/> 59 59 <UnitName Value="UGrammer"/> 60 <CursorPos X="1 " Y="322"/>61 <TopLine Value="3 07"/>60 <CursorPos X="10" Y="398"/> 61 <TopLine Value="384"/> 62 62 <EditorIndex Value="0"/> 63 <UsageCount Value="2 5"/>63 <UsageCount Value="27"/> 64 64 <Loaded Value="True"/> 65 65 </Unit2> … … 71 71 <TopLine Value="86"/> 72 72 <EditorIndex Value="3"/> 73 <UsageCount Value="2 5"/>73 <UsageCount Value="27"/> 74 74 <Loaded Value="True"/> 75 75 </Unit3> … … 83 83 <Filename Value="..\..\..\..\..\Programy\Lazarus_0.9.29\fpc\2.3.1\source\rtl\objpas\fgl.pp"/> 84 84 <UnitName Value="fgl"/> 85 <CursorPos X=" 3" Y="707"/>86 <TopLine Value="7 05"/>85 <CursorPos X="6" Y="730"/> 86 <TopLine Value="725"/> 87 87 <UsageCount Value="11"/> 88 88 </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> 89 95 </Units> 90 96 <JumpHistory Count="30" HistoryIndex="29"> 91 97 <Position1> 92 <Filename Value=" UProgram.pas"/>93 <Caret Line="1 05" Column="1" TopLine="90"/>98 <Filename Value="PascalCompiler.lpr"/> 99 <Caret Line="12" Column="11" TopLine="1"/> 94 100 </Position1> 95 101 <Position2> 96 <Filename Value=" UProgram.pas"/>97 <Caret Line="1 06" Column="1" TopLine="91"/>102 <Filename Value="PascalCompiler.lpr"/> 103 <Caret Line="18" Column="15" TopLine="1"/> 98 104 </Position2> 99 105 <Position3> 100 106 <Filename Value="UProgram.pas"/> 101 <Caret Line="1 07" Column="1" TopLine="92"/>107 <Caret Line="19" Column="20" TopLine="1"/> 102 108 </Position3> 103 109 <Position4> 104 <Filename Value="U Program.pas"/>105 <Caret Line=" 108" Column="1" TopLine="93"/>110 <Filename Value="UMainForm.pas"/> 111 <Caret Line="83" Column="15" TopLine="57"/> 106 112 </Position4> 107 113 <Position5> 108 <Filename Value="U Program.pas"/>109 <Caret Line=" 111" Column="1" TopLine="96"/>114 <Filename Value="UMainForm.pas"/> 115 <Caret Line="642" Column="15" TopLine="621"/> 110 116 </Position5> 111 117 <Position6> 112 <Filename Value="U Program.pas"/>113 <Caret Line=" 113" Column="1" TopLine="98"/>118 <Filename Value="UMainForm.pas"/> 119 <Caret Line="629" Column="55" TopLine="589"/> 114 120 </Position6> 115 121 <Position7> 116 <Filename Value="U Program.pas"/>117 <Caret Line=" 115" Column="1" TopLine="100"/>122 <Filename Value="UMainForm.pas"/> 123 <Caret Line="58" Column="20" TopLine="54"/> 118 124 </Position7> 119 125 <Position8> 120 126 <Filename Value="UProgram.pas"/> 121 <Caret Line="116" Column=" 1" TopLine="101"/>127 <Caret Line="116" Column="21" TopLine="93"/> 122 128 </Position8> 123 129 <Position9> 124 130 <Filename Value="UProgram.pas"/> 125 <Caret Line="11 7" Column="1" TopLine="102"/>131 <Caret Line="118" Column="22" TopLine="102"/> 126 132 </Position9> 127 133 <Position10> 128 134 <Filename Value="UGrammer.pas"/> 129 <Caret Line=" 322" Column="1" TopLine="307"/>135 <Caret Line="238" Column="10" TopLine="233"/> 130 136 </Position10> 131 137 <Position11> 132 138 <Filename Value="UGrammer.pas"/> 133 <Caret Line=" 323" Column="22" TopLine="309"/>139 <Caret Line="93" Column="22" TopLine="78"/> 134 140 </Position11> 135 141 <Position12> 136 142 <Filename Value="UGrammer.pas"/> 137 <Caret Line=" 324" Column="6" TopLine="311"/>143 <Caret Line="89" Column="57" TopLine="74"/> 138 144 </Position12> 139 145 <Position13> 140 <Filename Value="U Grammer.pas"/>141 <Caret Line=" 25" Column="12" TopLine="10"/>146 <Filename Value="UProgram.pas"/> 147 <Caret Line="119" Column="31" TopLine="96"/> 142 148 </Position13> 143 149 <Position14> 144 150 <Filename Value="UGrammer.pas"/> 145 <Caret Line=" 328" Column="32" TopLine="311"/>151 <Caret Line="102" Column="63" TopLine="88"/> 146 152 </Position14> 147 153 <Position15> … … 151 157 <Position16> 152 158 <Filename Value="UGrammer.pas"/> 153 <Caret Line="3 22" Column="1" TopLine="307"/>159 <Caret Line="309" Column="36" TopLine="286"/> 154 160 </Position16> 155 161 <Position17> 156 162 <Filename Value="UGrammer.pas"/> 157 <Caret Line=" 324" Column="1" TopLine="309"/>163 <Caret Line="25" Column="23" TopLine="10"/> 158 164 </Position17> 159 165 <Position18> 160 166 <Filename Value="UGrammer.pas"/> 161 <Caret Line=" 325" Column="1" TopLine="310"/>167 <Caret Line="22" Column="45" TopLine="7"/> 162 168 </Position18> 163 169 <Position19> 164 170 <Filename Value="UGrammer.pas"/> 165 <Caret Line="3 26" Column="1" TopLine="311"/>171 <Caret Line="309" Column="48" TopLine="371"/> 166 172 </Position19> 167 173 <Position20> 168 <Filename Value="U Grammer.pas"/>169 <Caret Line=" 327" Column="1" TopLine="312"/>174 <Filename Value="UProgram.pas"/> 175 <Caret Line="101" Column="1" TopLine="86"/> 170 176 </Position20> 171 177 <Position21> 172 178 <Filename Value="UGrammer.pas"/> 173 <Caret Line="32 9" Column="1" TopLine="314"/>179 <Caret Line="327" Column="36" TopLine="305"/> 174 180 </Position21> 175 181 <Position22> 176 <Filename Value="U Grammer.pas"/>177 <Caret Line=" 203" Column="1" TopLine="188"/>182 <Filename Value="UProgram.pas"/> 183 <Caret Line="101" Column="1" TopLine="86"/> 178 184 </Position22> 179 185 <Position23> 180 186 <Filename Value="UGrammer.pas"/> 181 <Caret Line=" 214" Column="1" TopLine="199"/>187 <Caret Line="320" Column="1" TopLine="305"/> 182 188 </Position23> 183 189 <Position24> 184 <Filename Value="U Grammer.pas"/>185 <Caret Line=" 215" Column="1" TopLine="200"/>190 <Filename Value="UProgram.pas"/> 191 <Caret Line="101" Column="1" TopLine="86"/> 186 192 </Position24> 187 193 <Position25> 188 194 <Filename Value="UGrammer.pas"/> 189 <Caret Line="3 22" Column="1" TopLine="307"/>195 <Caret Line="316" Column="11" TopLine="310"/> 190 196 </Position25> 191 197 <Position26> 192 198 <Filename Value="UGrammer.pas"/> 193 <Caret Line=" 324" Column="1" TopLine="309"/>199 <Caret Line="292" Column="22" TopLine="277"/> 194 200 </Position26> 195 201 <Position27> 196 202 <Filename Value="UGrammer.pas"/> 197 <Caret Line=" 325" Column="1" TopLine="310"/>203 <Caret Line="43" Column="26" TopLine="28"/> 198 204 </Position27> 199 205 <Position28> 200 206 <Filename Value="UGrammer.pas"/> 201 <Caret Line="3 26" Column="1" TopLine="311"/>207 <Caret Line="38" Column="62" TopLine="23"/> 202 208 </Position28> 203 209 <Position29> 204 210 <Filename Value="UGrammer.pas"/> 205 <Caret Line=" 327" Column="1" TopLine="312"/>211 <Caret Line="290" Column="39" TopLine="283"/> 206 212 </Position29> 207 213 <Position30> 208 214 <Filename Value="UGrammer.pas"/> 209 <Caret Line="3 26" Column="1" TopLine="311"/>215 <Caret Line="38" Column="17" TopLine="17"/> 210 216 </Position30> 211 217 </JumpHistory> … … 231 237 </CompilerOptions> 232 238 <Debugging> 233 <BreakPoints Count=" 2">239 <BreakPoints Count="3"> 234 240 <Item1> 235 241 <Source Value="UMainForm.pas"/> … … 240 246 <Line Value="101"/> 241 247 </Item2> 248 <Item3> 249 <Source Value="UGrammer.pas"/> 250 <Line Value="323"/> 251 </Item3> 242 252 </BreakPoints> 243 253 <Exceptions Count="3"> -
branches/Analyzátor gramatiky/UGrammer.pas
r30 r31 30 30 end; 31 31 32 { TPossibleCharacter } 33 32 34 TPossibleCharacter = class 33 35 Character: Char; 34 36 RulePath: TGrammerPath; 35 37 procedure Assign(Source: TPossibleCharacter); 38 constructor Create; 39 destructor Destroy; override; 36 40 end; 37 41 … … 138 142 I: Integer; 139 143 begin 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); 141 146 end; 142 147 … … 146 151 begin 147 152 for I := 0 to Items.Count - 1 do 148 with Items[I] do begin 149 Processed := False; 150 end; 153 Items[I].Processed := False; 151 154 end; 152 155 … … 183 186 if UseIndex > 0 then begin 184 187 // 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 186 190 NextItemIndex := ItemIndex; 187 191 NextCharIndex := CharIndex; … … 237 241 begin 238 242 for I := 0 to Rules.Count - 1 do 239 with Rules[I] do begin 240 ClearProcessed; 241 end; 243 Rules[I].ClearProcessed; 242 244 end; 243 245 … … 250 252 for I := 0 to Rules.Count - 1 do with Rules[I] do begin 251 253 for II := 0 to Items.Count - 1 do with Items[II] do begin 252 if (ItemType = itNonterminal) and ( Rule = nil) then begin254 if (ItemType = itNonterminal) and (not Assigned(Rule)) then begin 253 255 J := 0; 254 while (J < Rules.Count) and (Rules[J].Name <> RuleName) 256 while (J < Rules.Count) and (Rules[J].Name <> RuleName) do Inc(J); 255 257 if J < Rules.Count then Rule := Rules[J] else 256 258 raise Exception.Create('Rule link correction failed on rule ' + … … 309 311 NextRule := Rule; 310 312 end; 311 Path.Items. Count := Path.Items.Count - 1;313 Path.Items.Delete(Path.Items.Count - 1); 312 314 NextRule.GetPossibleCharacters(Path, Characters, NextItemIndex + 1, NextCharIndex); 313 315 end; … … 380 382 end; 381 383 384 constructor TPossibleCharacter.Create; 385 begin 386 RulePath := TGrammerPath.Create; 387 end; 388 389 destructor TPossibleCharacter.Destroy; 390 begin 391 RulePath.Destroy; 392 inherited Destroy; 393 end; 394 382 395 { TPossibleCharacters } 383 396 -
branches/Analyzátor gramatiky/UMainForm.lrs
r29 r31 1 { Toto je automaticky generovanÜ zdrojovÜ soubor lazarusu } 2 1 3 LazarusResources.Add('TMainForm','FORMDATA',[ 2 4 '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 627 627 if Assigned(SourceProgram.Items[I]) then 628 628 //TreeView1.Items.AddChild(TreeNode, IntToStr(I)) 629 ShowProgramNode(TreeNode, TProgramItem(SourceProgram.Items[I]))629 ShowProgramNode(TreeNode, SourceProgram.Items[I]) 630 630 else TreeView1.Items.AddChild(TreeNode, 'x'); 631 631 end else begin -
branches/Analyzátor gramatiky/UProgram.pas
r30 r31 72 72 if not Assigned(SelectedProgramItem.Items[CharIndex]) then 73 73 SelectedProgramItem.Items[CharIndex] := TProgramItem.Create; 74 SelectedProgramItem := TProgramItem(SelectedProgramItem.Items[CharIndex]);74 SelectedProgramItem := SelectedProgramItem.Items[CharIndex]; 75 75 (* end else begin 76 76 SelectedProgramItem.Items.Count := SelectedProgramItem.Items.Count + 1; … … 109 109 end; 110 110 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 115 113 UseIndex := Path.Items[Path.Items.Count - 1].ItemIndex; 116 114 UseCharIndex := Path.Items[Path.Items.Count - 1].CharIndex; … … 208 206 I: Integer; 209 207 begin 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 211 210 if ItemType = itNonterminal then begin 212 211 if Rule.Name = ARule.Name then begin … … 235 234 begin 236 235 for I := 0 to Items.Count - 1 do 237 with TProgramItem(Items[I])do begin236 with Items[I] do begin 238 237 if ItemType = itNonterminal then Delete; 239 238 end; … … 246 245 I := 0; 247 246 while I < Items.Count do 248 with TProgramItem(Items[I])do begin247 with Items[I] do begin 249 248 if ItemType = itNonterminal then begin 250 249 if Items.Count = 0 then begin … … 260 259 procedure TProgramItem.DeleteItem(Index: Integer); 261 260 begin 262 if TProgramItem(Items[Index]).ItemType = itNonterminal then263 TProgramItem(Items[Index]).Delete;261 if Items[Index].ItemType = itNonterminal then 262 Items[Index].Delete; 264 263 Items.Delete(Index); 265 264 end; … … 314 313 begin 315 314 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 317 317 if ItemType = itTerminal then Result := Result + Value 318 318 else Result := Result + MergeToTerminal;
Note:
See TracChangeset
for help on using the changeset viewer.