Changeset 17 for branches/Void
- Timestamp:
- Nov 10, 2009, 11:13:51 AM (15 years ago)
- Location:
- branches/Void
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Void
- Property svn:ignore
-
old new 7 7 *.dsk 8 8 *.~dsk 9 Output.bdsproj 10 Output.c 11 Output.dpr 12 Output.exe
-
- Property svn:ignore
-
branches/Void/UCompilator.pas
r16 r17 10 10 type 11 11 TOnErrorEvent = procedure (Text: string; var Terminate: Boolean; Position: TPoint) of object; 12 13 TErrorMessage = class 14 CodePosition: TPoint; 15 Text: string; 16 end; 12 17 13 18 TCompilator = class 14 19 private 15 20 FOnError: TOnErrorEvent; 16 procedure DoError( Text: string);21 procedure DoError(AText: string); 17 22 procedure ParseBeginEnd; 18 23 procedure ParseProgram; 19 24 procedure ParseVariableDefinition; 20 25 public 26 ErrorMessages: TList; 21 27 Model: TModel; 22 28 SourceCode: TStream; … … 33 39 { TCompilator } 34 40 35 procedure TCompilator.DoError( Text: string);41 procedure TCompilator.DoError(AText: string); 36 42 var 37 43 Terminate: Boolean; 38 44 begin 45 with TErrorMessage(ErrorMessages[ErrorMessages.Add(TErrorMessage.Create)]) do begin 46 CodePosition := Parser.TokenStartPosition; 47 Text := AText; 48 end; 39 49 Terminate := False; 40 if Assigned(FOnError) then FOnError( Text, Terminate, Parser.TokenStartPosition);50 if Assigned(FOnError) then FOnError(AText, Terminate, Parser.TokenStartPosition); 41 51 if Terminate then raise Exception.Create('Compilation terminated'); 42 52 end; … … 123 133 begin 124 134 Model.Clear; 135 for I := 0 to ErrorMessages.Count - 1 do 136 TErrorMessage(ErrorMessages[I]).Destroy; 137 ErrorMessages.Clear; 125 138 SourceCode.Position := 0; 126 139 Parser.Open(SourceCode); … … 250 263 constructor TCompilator.Create; 251 264 begin 265 ErrorMessages := TList.Create; 252 266 SourceCode := TMemoryStream.Create; 253 267 Model := TModel.Create; … … 256 270 257 271 destructor TCompilator.Destroy; 258 begin 272 var 273 I: Integer; 274 begin 275 for I := 0 to ErrorMessages.Count - 1 do 276 TErrorMessage(ErrorMessages[I]).Destroy; 277 ErrorMessages.Destroy; 259 278 SourceCode.Destroy; 260 279 Model.Destroy; -
branches/Void/UMainForm.lfm
r16 r17 1 1 object MainForm: TMainForm 2 Left = 25 93 Height = 5 804 Top = 652 Left = 257 3 Height = 527 4 Top = 134 5 5 Width = 760 6 6 Caption = 'Překladač Void' 7 ClientHeight = 5 807 ClientHeight = 527 8 8 ClientWidth = 760 9 9 OnClose = FormClose … … 28 28 ParentColor = False 29 29 end 30 object Memo3: TMemo31 Left = 932 Height = 7733 Top = 44334 Width = 54935 ScrollBars = ssAutoBoth36 TabOrder = 037 end38 30 object Label3: TLabel 39 31 Left = 12 … … 51 43 Caption = 'Přeložit' 52 44 OnClick = ButtonCompileClick 53 TabOrder = 145 TabOrder = 0 54 46 end 55 47 object ComboBox1: TComboBox … … 66 58 ) 67 59 Style = csDropDownList 68 TabOrder = 260 TabOrder = 1 69 61 Text = 'Pascal' 70 62 end … … 80 72 ParentColor = False 81 73 ParentFont = False 82 TabOrder = 3 74 TabOrder = 2 75 BookMarkOptions.OnChange = nil 83 76 Gutter.Width = 57 84 77 Gutter.MouseActions = < … … 773 766 ParentColor = False 774 767 ParentFont = False 775 TabOrder = 4 768 TabOrder = 3 769 BookMarkOptions.OnChange = nil 776 770 Gutter.Width = 57 777 771 Gutter.MouseActions = < … … 1346 1340 ) 1347 1341 BracketHighlightStyle = sbhsBoth 1348 OnChange = SynEdit2Change1349 1342 inline SynGutterPartList1: TSynGutterPartList 1350 1343 object SynGutterMarks1: TSynGutterMarks … … 1461 1454 Width = 185 1462 1455 DefaultItemHeight = 15 1463 TabOrder = 51456 TabOrder = 4 1464 1457 end 1465 1458 object Label4: TLabel … … 1470 1463 Caption = 'Struktura:' 1471 1464 ParentColor = False 1465 end 1466 object ListView1: TListView 1467 Left = 9 1468 Height = 72 1469 Top = 446 1470 Width = 479 1471 Columns = < 1472 item 1473 Caption = 'Modul' 1474 Width = 100 1475 end 1476 item 1477 Caption = 'Pozice' 1478 end 1479 item 1480 Caption = 'Hlášení' 1481 Width = 300 1482 end> 1483 ReadOnly = True 1484 RowSelect = True 1485 TabOrder = 5 1486 ViewStyle = vsReport 1487 OnClick = ListView1Click 1472 1488 end 1473 1489 object SynPasSyn1: TSynPasSyn -
branches/Void/UMainForm.pas
r16 r17 25 25 Label3: TLabel; 26 26 Label4: TLabel; 27 Memo3: TMemo;27 ListView1: TListView; 28 28 SynCppSyn1: TSynCppSyn; 29 29 SynEdit1: TSynEdit; … … 36 36 procedure FormDestroy(Sender: TObject); 37 37 procedure FormShow(Sender: TObject); 38 procedure SynEdit2Change(Sender: TObject);38 procedure ListView1Click(Sender: TObject); 39 39 private 40 40 SourceCode: TMemoryStream; … … 59 59 end; 60 60 61 procedure TMainForm. SynEdit2Change(Sender: TObject);61 procedure TMainForm.ListView1Click(Sender: TObject); 62 62 begin 63 63 if Assigned(ListView1.Selected) then begin 64 SynEdit1.CaretXY := TErrorMessage(Compilator.ErrorMessages[ 65 ListView1.Selected.Index]).CodePosition; 66 SynEdit1.SetFocus; 67 end; 64 68 end; 65 69 … … 85 89 var 86 90 Code: string; 91 OutputFileName: string; 87 92 begin 88 93 with Compilator do begin 89 Memo3.Lines.Clear;94 ListView1.Clear; 90 95 Code := SynEdit1.Lines.Text; 91 96 SourceCode.Size := 0; … … 95 100 Generator := TPascalGenerator.Create; 96 101 SynEdit2.Highlighter := SynPasSyn1; 102 OutputFileName := 'Output.dpr'; 97 103 end else 98 104 if ComboBox1.ItemIndex = 1 then begin 99 105 Generator := TCGenerator.Create; 100 106 SynEdit2.Highlighter := SynCppSyn1; 107 OutputFileName := 'Output.c'; 101 108 end else 102 109 if ComboBox1.ItemIndex = 2 then begin 103 110 Generator := TZ80Generator.Create; 104 111 SynEdit2.Highlighter := SynCppSyn1; 112 OutputFileName := 'Output.asm'; 105 113 end; 106 Compile; 114 115 try 116 Compile; 117 except 118 end; 119 107 120 SynEdit2.Lines.Assign(Generator.Output); 121 SynEdit2.Lines.SaveToFile(OutputFileName); 108 122 ModelViewer.Show(TreeView1); 109 123 end; … … 112 126 procedure TMainForm.CompilatorError(Text: string; var Terminate: Boolean; 113 127 Position: TPoint); 128 var 129 NewItem: TListItem; 114 130 begin 115 131 Terminate := False; 116 Memo3.Lines.Add('(' + IntToStr(Position.X) + ', ' + IntToStr(Position.Y) + ') Error: ' + Text); 132 NewItem := ListView1.Items.Add; 133 with NewItem do begin 134 Caption := ''; 135 SubItems.Add(IntToStr(Position.X) + ', ' + IntToStr(Position.Y)); 136 SubItems.Add('Error: ' + Text); 137 end; 117 138 end; 118 139 -
branches/Void/project1.lpi
r16 r17 9 9 <Icon Value="0"/> 10 10 <UseXPManifest Value="True"/> 11 <ActiveEditorIndexAtStart Value=" 6"/>11 <ActiveEditorIndexAtStart Value="1"/> 12 12 </General> 13 13 <VersionInfo> … … 42 42 <IsPartOfProject Value="True"/> 43 43 <UnitName Value="project1"/> 44 <CursorPos X="15" Y="17"/> 45 <TopLine Value="1"/> 46 <EditorIndex Value="6"/> 47 <UsageCount Value="46"/> 48 <Loaded Value="True"/> 44 <CursorPos X="51" Y="9"/> 45 <TopLine Value="1"/> 46 <UsageCount Value="47"/> 49 47 </Unit0> 50 48 <Unit1> … … 54 52 <ResourceBaseClass Value="Form"/> 55 53 <UnitName Value="UMainForm"/> 56 <CursorPos X=" 83" Y="86"/>57 <TopLine Value=" 20"/>54 <CursorPos X="21" Y="131"/> 55 <TopLine Value="114"/> 58 56 <EditorIndex Value="0"/> 59 <UsageCount Value="4 6"/>57 <UsageCount Value="47"/> 60 58 <Loaded Value="True"/> 61 59 </Unit1> … … 63 61 <Filename Value="UCompilator.pas"/> 64 62 <UnitName Value="UCompilator"/> 65 <CursorPos X=" 33" Y="182"/>66 <TopLine Value="1 61"/>63 <CursorPos X="18" Y="135"/> 64 <TopLine Value="130"/> 67 65 <EditorIndex Value="2"/> 68 <UsageCount Value="2 3"/>66 <UsageCount Value="24"/> 69 67 <Loaded Value="True"/> 70 68 </Unit2> … … 76 74 <TopLine Value="7"/> 77 75 <EditorIndex Value="4"/> 78 <UsageCount Value="4 6"/>76 <UsageCount Value="47"/> 79 77 <Loaded Value="True"/> 80 78 </Unit3> … … 82 80 <Filename Value="Example.void"/> 83 81 <IsPartOfProject Value="True"/> 84 <CursorPos X=" 4" Y="1"/>85 <TopLine Value="1"/> 86 <UsageCount Value="4 6"/>82 <CursorPos X="8" Y="7"/> 83 <TopLine Value="1"/> 84 <UsageCount Value="47"/> 87 85 <SyntaxHighlighter Value="None"/> 88 86 </Unit4> … … 93 91 <CursorPos X="11" Y="75"/> 94 92 <TopLine Value="53"/> 95 <EditorIndex Value=" 9"/>96 <UsageCount Value="4 6"/>93 <EditorIndex Value="8"/> 94 <UsageCount Value="47"/> 97 95 <Loaded Value="True"/> 98 96 </Unit5> … … 129 127 <TopLine Value="140"/> 130 128 <EditorIndex Value="3"/> 131 <UsageCount Value="4 6"/>129 <UsageCount Value="47"/> 132 130 <Loaded Value="True"/> 133 131 </Unit10> … … 162 160 <IsPartOfProject Value="True"/> 163 161 <UnitName Value="UModelViewer"/> 164 <CursorPos X=" 41" Y="31"/>162 <CursorPos X="14" Y="19"/> 165 163 <TopLine Value="16"/> 166 164 <EditorIndex Value="1"/> 167 <UsageCount Value="2 2"/>165 <UsageCount Value="23"/> 168 166 <Loaded Value="True"/> 169 167 </Unit15> … … 181 179 <TopLine Value="47"/> 182 180 <EditorIndex Value="5"/> 183 <UsageCount Value="2 1"/>181 <UsageCount Value="22"/> 184 182 <Loaded Value="True"/> 185 183 </Unit17> … … 190 188 <CursorPos X="56" Y="8"/> 191 189 <TopLine Value="1"/> 192 <EditorIndex Value=" 8"/>193 <UsageCount Value="2 1"/>190 <EditorIndex Value="7"/> 191 <UsageCount Value="22"/> 194 192 <Loaded Value="True"/> 195 193 </Unit18> … … 198 196 <IsPartOfProject Value="True"/> 199 197 <UnitName Value="UPascalGenerator"/> 200 <CursorPos X=" 1" Y="35"/>201 <TopLine Value=" 13"/>202 <EditorIndex Value=" 7"/>203 <UsageCount Value="2 1"/>198 <CursorPos X="27" Y="61"/> 199 <TopLine Value="53"/> 200 <EditorIndex Value="6"/> 201 <UsageCount Value="22"/> 204 202 <Loaded Value="True"/> 205 203 </Unit19> … … 208 206 <Position1> 209 207 <Filename Value="UMainForm.pas"/> 210 <Caret Line=" 74" Column="49" TopLine="61"/>208 <Caret Line="105" Column="1" TopLine="79"/> 211 209 </Position1> 212 210 <Position2> 213 211 <Filename Value="UMainForm.pas"/> 214 <Caret Line=" 84" Column="44" TopLine="69"/>212 <Caret Line="41" Column="1" TopLine="26"/> 215 213 </Position2> 216 214 <Position3> 217 215 <Filename Value="UMainForm.pas"/> 218 <Caret Line=" 92" Column="33" TopLine="60"/>216 <Caret Line="39" Column="31" TopLine="17"/> 219 217 </Position3> 220 218 <Position4> 221 <Filename Value="UM ainForm.pas"/>222 <Caret Line=" 93" Column="33" TopLine="63"/>219 <Filename Value="UModelViewer.pas"/> 220 <Caret Line="23" Column="12" TopLine="1"/> 223 221 </Position4> 224 222 <Position5> 225 <Filename Value="UM ainForm.pas"/>226 <Caret Line=" 92" Column="33" TopLine="63"/>223 <Filename Value="UModelViewer.pas"/> 224 <Caret Line="25" Column="25" TopLine="5"/> 227 225 </Position5> 228 226 <Position6> 229 <Filename Value="UM ainForm.pas"/>230 <Caret Line=" 93" Column="33" TopLine="63"/>227 <Filename Value="UModelViewer.pas"/> 228 <Caret Line="17" Column="48" TopLine="4"/> 231 229 </Position6> 232 230 <Position7> 233 <Filename Value="UM ainForm.pas"/>234 <Caret Line=" 41" Column="29" TopLine="16"/>231 <Filename Value="UModelViewer.pas"/> 232 <Caret Line="26" Column="3" TopLine="15"/> 235 233 </Position7> 236 234 <Position8> 237 <Filename Value="UM ainForm.pas"/>238 <Caret Line="1 13" Column="1" TopLine="83"/>235 <Filename Value="UModelViewer.pas"/> 236 <Caret Line="17" Column="46" TopLine="2"/> 239 237 </Position8> 240 238 <Position9> 241 <Filename Value="UM ainForm.pas"/>242 <Caret Line=" 110" Column="32" TopLine="90"/>239 <Filename Value="UModelViewer.pas"/> 240 <Caret Line="36" Column="11" TopLine="15"/> 243 241 </Position9> 244 242 <Position10> 245 <Filename Value="U MainForm.pas"/>246 <Caret Line=" 113" Column="49" TopLine="89"/>243 <Filename Value="UCompilator.pas"/> 244 <Caret Line="220" Column="82" TopLine="207"/> 247 245 </Position10> 248 246 <Position11> 249 <Filename Value="U ModelViewer.pas"/>250 <Caret Line=" 16" Column="17" TopLine="1"/>247 <Filename Value="UVoidParser.pas"/> 248 <Caret Line="89" Column="29" TopLine="72"/> 251 249 </Position11> 252 250 <Position12> 253 <Filename Value="U MainForm.pas"/>254 <Caret Line=" 105" Column="1" TopLine="79"/>251 <Filename Value="UOutputGenerator.pas"/> 252 <Caret Line="78" Column="42" TopLine="53"/> 255 253 </Position12> 256 254 <Position13> 257 255 <Filename Value="UMainForm.pas"/> 258 <Caret Line=" 41" Column="1" TopLine="26"/>256 <Caret Line="10" Column="16" TopLine="1"/> 259 257 </Position13> 260 258 <Position14> 261 <Filename Value=" UMainForm.pas"/>262 <Caret Line=" 39" Column="31" TopLine="17"/>259 <Filename Value="Generators\UPascalGenerator.pas"/> 260 <Caret Line="8" Column="56" TopLine="1"/> 263 261 </Position14> 264 262 <Position15> 265 <Filename Value=" UModelViewer.pas"/>266 <Caret Line=" 23" Column="12" TopLine="1"/>263 <Filename Value="Generators\UPascalGenerator.pas"/> 264 <Caret Line="56" Column="18" TopLine="1"/> 267 265 </Position15> 268 266 <Position16> 269 <Filename Value=" UModelViewer.pas"/>270 <Caret Line=" 25" Column="25" TopLine="5"/>267 <Filename Value="Generators\UPascalGenerator.pas"/> 268 <Caret Line="11" Column="36" TopLine="1"/> 271 269 </Position16> 272 270 <Position17> 273 <Filename Value=" UModelViewer.pas"/>274 <Caret Line=" 17" Column="48" TopLine="4"/>271 <Filename Value="Generators\UZ80Generator.pas"/> 272 <Caret Line="8" Column="56" TopLine="4"/> 275 273 </Position17> 276 274 <Position18> 277 <Filename Value="UM odelViewer.pas"/>278 <Caret Line=" 26" Column="3" TopLine="15"/>275 <Filename Value="UMainForm.pas"/> 276 <Caret Line="94" Column="1" TopLine="71"/> 279 277 </Position18> 280 278 <Position19> 281 <Filename Value="UM odelViewer.pas"/>282 <Caret Line=" 17" Column="46" TopLine="2"/>279 <Filename Value="UMainForm.pas"/> 280 <Caret Line="97" Column="28" TopLine="1"/> 283 281 </Position19> 284 282 <Position20> 285 <Filename Value="U ModelViewer.pas"/>286 <Caret Line=" 36" Column="11" TopLine="15"/>283 <Filename Value="UCompilator.pas"/> 284 <Caret Line="269" Column="19" TopLine="243"/> 287 285 </Position20> 288 286 <Position21> 289 287 <Filename Value="UCompilator.pas"/> 290 <Caret Line=" 220" Column="82" TopLine="207"/>288 <Caret Line="41" Column="40" TopLine="23"/> 291 289 </Position21> 292 290 <Position22> 293 <Filename Value="U VoidParser.pas"/>294 <Caret Line=" 89" Column="29" TopLine="72"/>291 <Filename Value="UMainForm.pas"/> 292 <Caret Line="110" Column="5" TopLine="60"/> 295 293 </Position22> 296 294 <Position23> 297 <Filename Value="U OutputGenerator.pas"/>298 <Caret Line=" 78" Column="42" TopLine="53"/>295 <Filename Value="UMainForm.pas"/> 296 <Caret Line="109" Column="5" TopLine="79"/> 299 297 </Position23> 300 298 <Position24> 301 299 <Filename Value="UMainForm.pas"/> 302 <Caret Line="1 0" Column="16" TopLine="1"/>300 <Caret Line="110" Column="5" TopLine="80"/> 303 301 </Position24> 304 302 <Position25> 305 <Filename Value=" Generators\UPascalGenerator.pas"/>306 <Caret Line=" 8" Column="56" TopLine="1"/>303 <Filename Value="UMainForm.pas"/> 304 <Caret Line="90" Column="15" TopLine="75"/> 307 305 </Position25> 308 306 <Position26> 309 <Filename Value=" Generators\UPascalGenerator.pas"/>310 <Caret Line=" 56" Column="18" TopLine="1"/>307 <Filename Value="UMainForm.pas"/> 308 <Caret Line="119" Column="34" TopLine="105"/> 311 309 </Position26> 312 310 <Position27> 313 <Filename Value=" Generators\UPascalGenerator.pas"/>314 <Caret Line="1 1" Column="36" TopLine="1"/>311 <Filename Value="UMainForm.pas"/> 312 <Caret Line="10" Column="32" TopLine="1"/> 315 313 </Position27> 316 314 <Position28> 317 <Filename Value=" Generators\UZ80Generator.pas"/>318 <Caret Line=" 8" Column="56" TopLine="4"/>315 <Filename Value="UMainForm.pas"/> 316 <Caret Line="40" Column="5" TopLine="25"/> 319 317 </Position28> 320 318 <Position29> 321 319 <Filename Value="UMainForm.pas"/> 322 <Caret Line=" 94" Column="1" TopLine="71"/>320 <Caret Line="10" Column="32" TopLine="1"/> 323 321 </Position29> 324 322 <Position30> 325 <Filename Value=" project1.lpr"/>326 <Caret Line=" 10" Column="33" TopLine="1"/>323 <Filename Value="UMainForm.pas"/> 324 <Caret Line="67" Column="1" TopLine="53"/> 327 325 </Position30> 328 326 </JumpHistory>
Note:
See TracChangeset
for help on using the changeset viewer.