Changeset 58
- Timestamp:
- Aug 10, 2010, 3:41:49 PM (14 years ago)
- Location:
- branches/Transpascal
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Analyze/UParser.pas
r55 r58 57 57 procedure ParseProgram(SourceCode: TModuleProgram); 58 58 procedure ParseCommonBlock(SourceCode: TCommonBlock; EndSymbol: char = ';'); 59 procedure ParseCommonBlockInterface(SourceCode: TCommonBlock); 59 60 function ParseCommand(SourceCode: TCommonBlock): TCommand; 60 61 procedure ParseBeginEnd(SourceCode: TBeginEnd); 61 procedure ParseFunctionList(SourceCode: TFunctionList );62 procedure ParseFunctionList(SourceCode: TFunctionList; IncludeBody: Boolean = True); 62 63 procedure ParseIfThenElse(SourceCode: TIfThenElse); 63 64 procedure ParseForToDo(SourceCode: TForToDo); … … 682 683 ParseUsedModuleList(SourceCode.UsedModules); 683 684 684 ParseCommonBlock (SourceCode.Body, '.');685 ParseCommonBlockInterface(SourceCode.Body); 685 686 end; 686 687 … … 725 726 end; 726 727 728 procedure TPascalParser.ParseCommonBlockInterface(SourceCode: TCommonBlock); 729 begin 730 with SourceCode do begin 731 while FNextToken <> 'implementation' do begin 732 if FNextToken = 'var' then 733 ParseVariableList(Variables) 734 else if FNextToken = 'const' then 735 ParseConstantList(Constants) 736 else if FNextToken = 'type' then 737 ParseTypeList(Types) 738 else if FNextToken = 'procedure' then 739 ParseFunctionList(Functions, False) 740 else if FNextToken = 'function' then 741 ParseFunctionList(Functions, False) 742 else ErrorMessage(SUnknownIdentifier, [FNextToken]); 743 end; 744 end; 745 end; 746 727 747 { TParserBeginEnd } 728 748 … … 750 770 { TParserParseFunctionList } 751 771 752 procedure TPascalParser.ParseFunctionList(SourceCode: TFunctionList );772 procedure TPascalParser.ParseFunctionList(SourceCode: TFunctionList; IncludeBody: Boolean = True); 753 773 var 754 774 Identifiers: TStringList; … … 760 780 begin 761 781 Identifiers := TStringList.Create; 762 with SourceCode do 763 begin 764 with TFunction(Items[Add(TFunction.Create)]) do 765 begin 782 with SourceCode do begin 783 with TFunction(Items[Add(TFunction.Create)]) do begin 766 784 Parent := SourceCode.Parent; 767 785 if FNextToken = 'procedure' then … … 834 852 end; 835 853 end; 836 end; 837 Expect(';'); 838 ParseCommonBlock(TFunction(Last)); 854 Expect(';'); 855 856 // Check directives 857 if FNextToken = 'internal' then begin 858 Expect('internal'); 859 Expect(';'); 860 System := True; 861 end; 862 end; 863 864 if IncludeBody then ParseCommonBlock(TFunction(Last)); 839 865 end; 840 866 Identifiers.Destroy; -
branches/Transpascal/Project/System.pas
r55 r58 4 4 5 5 type 6 Void = System;7 Byte = System;8 ShortInt = System;9 Word = System;10 SmallInt = System;11 Cardinal = System;6 Void = internal; 7 Byte = internal; 8 ShortInt = internal; 9 Word = internal; 10 SmallInt = internal; 11 Cardinal = internal; 12 12 DWord = Cardinal; 13 Integer = System;14 QWord = System;15 Int64 = System;16 Char = System;13 Integer = internal; 14 QWord = internal; 15 Int64 = internal; 16 Char = internal; 17 17 String = array of Char; 18 18 19 19 20 procedure Exit; system;21 procedure Break; system;22 procedure Continue; system;20 procedure Exit; internal; 21 procedure Break; internal; 22 procedure Continue; internal; 23 23 24 24 implementation -
branches/Transpascal/Transpascal.lpi
r55 r58 50 50 <TopLine Value="4"/> 51 51 <CursorPos X="1" Y="29"/> 52 <UsageCount Value="1 48"/>52 <UsageCount Value="152"/> 53 53 <Loaded Value="True"/> 54 54 </Unit0> … … 60 60 <ResourceBaseClass Value="Form"/> 61 61 <UnitName Value="UMainForm"/> 62 <IsVisibleTab Value="True"/>63 62 <EditorIndex Value="6"/> 64 63 <WindowIndex Value="0"/> 65 <TopLine Value=" 207"/>66 <CursorPos X="1 0" Y="224"/>67 <UsageCount Value="1 48"/>64 <TopLine Value="66"/> 65 <CursorPos X="1" Y="85"/> 66 <UsageCount Value="152"/> 68 67 <Loaded Value="True"/> 69 68 <LoadedDesigner Value="True"/> … … 76 75 <TopLine Value="1"/> 77 76 <CursorPos X="1" Y="1"/> 78 <UsageCount Value="1 48"/>77 <UsageCount Value="152"/> 79 78 </Unit2> 80 79 <Unit3> … … 86 85 <TopLine Value="761"/> 87 86 <CursorPos X="13" Y="784"/> 88 <UsageCount Value="1 48"/>87 <UsageCount Value="152"/> 89 88 <Loaded Value="True"/> 90 89 </Unit3> … … 93 92 <IsPartOfProject Value="True"/> 94 93 <UnitName Value="UCompiler"/> 94 <IsVisibleTab Value="True"/> 95 95 <EditorIndex Value="14"/> 96 96 <WindowIndex Value="0"/> 97 <TopLine Value=" 1"/>98 <CursorPos X=" 5" Y="17"/>99 <UsageCount Value="1 48"/>97 <TopLine Value="34"/> 98 <CursorPos X="68" Y="51"/> 99 <UsageCount Value="152"/> 100 100 <Loaded Value="True"/> 101 101 </Unit4> … … 108 108 <TopLine Value="179"/> 109 109 <CursorPos X="3" Y="196"/> 110 <UsageCount Value="1 48"/>110 <UsageCount Value="152"/> 111 111 <Loaded Value="True"/> 112 112 </Unit5> … … 119 119 <TopLine Value="1"/> 120 120 <CursorPos X="38" Y="12"/> 121 <UsageCount Value="1 48"/>121 <UsageCount Value="152"/> 122 122 <Loaded Value="True"/> 123 123 </Unit6> … … 130 130 <TopLine Value="104"/> 131 131 <CursorPos X="52" Y="119"/> 132 <UsageCount Value="1 48"/>132 <UsageCount Value="152"/> 133 133 <Loaded Value="True"/> 134 134 </Unit7> … … 139 139 <EditorIndex Value="0"/> 140 140 <WindowIndex Value="0"/> 141 <TopLine Value=" 680"/>142 <CursorPos X="2 5" Y="689"/>143 <UsageCount Value="1 48"/>141 <TopLine Value="42"/> 142 <CursorPos X="26" Y="55"/> 143 <UsageCount Value="152"/> 144 144 <Loaded Value="True"/> 145 145 </Unit8> … … 159 159 <TopLine Value="936"/> 160 160 <CursorPos X="23" Y="949"/> 161 <UsageCount Value="1 0"/>161 <UsageCount Value="12"/> 162 162 <Loaded Value="True"/> 163 163 </Unit10> … … 168 168 <TopLine Value="61"/> 169 169 <CursorPos X="7" Y="68"/> 170 <UsageCount Value="5 7"/>170 <UsageCount Value="59"/> 171 171 <Loaded Value="True"/> 172 172 </Unit11> … … 177 177 <TopLine Value="139"/> 178 178 <CursorPos X="16" Y="146"/> 179 <UsageCount Value="5 7"/>179 <UsageCount Value="59"/> 180 180 <Loaded Value="True"/> 181 181 </Unit12> … … 209 209 <TopLine Value="277"/> 210 210 <CursorPos X="26" Y="291"/> 211 <UsageCount Value="11 0"/>211 <UsageCount Value="114"/> 212 212 <Loaded Value="True"/> 213 213 </Unit16> … … 233 233 <EditorIndex Value="8"/> 234 234 <WindowIndex Value="0"/> 235 <TopLine Value=" 77"/>236 <CursorPos X=" 34" Y="93"/>237 <UsageCount Value="6 4"/>235 <TopLine Value="141"/> 236 <CursorPos X="1" Y="154"/> 237 <UsageCount Value="68"/> 238 238 <Loaded Value="True"/> 239 239 </Unit19> … … 244 244 <EditorIndex Value="11"/> 245 245 <WindowIndex Value="0"/> 246 <TopLine Value=" 78"/>247 <CursorPos X="1" Y=" 99"/>248 <UsageCount Value="2 0"/>246 <TopLine Value="129"/> 247 <CursorPos X="1" Y="151"/> 248 <UsageCount Value="24"/> 249 249 <Loaded Value="True"/> 250 250 </Unit20> … … 255 255 <TopLine Value="17"/> 256 256 <CursorPos X="11" Y="30"/> 257 <UsageCount Value="1 0"/>257 <UsageCount Value="12"/> 258 258 <Loaded Value="True"/> 259 259 </Unit21> 260 260 </Units> 261 <JumpHistory Count="30" HistoryIndex="2 9">261 <JumpHistory Count="30" HistoryIndex="22"> 262 262 <Position1> 263 263 <Filename Value="Forms\UMainForm.pas"/> 264 <Caret Line="1 31" Column="21" TopLine="118"/>264 <Caret Line="124" Column="1" TopLine="110"/> 265 265 </Position1> 266 266 <Position2> 267 <Filename Value=" Forms\UMainForm.pas"/>268 <Caret Line=" 120" Column="40" TopLine="109"/>267 <Filename Value="Analyze\UParser.pas"/> 268 <Caret Line="61" Column="1" TopLine="48"/> 269 269 </Position2> 270 270 <Position3> 271 <Filename Value=" UProject.pas"/>272 <Caret Line=" 30" Column="58" TopLine="14"/>271 <Filename Value="Analyze\UParser.pas"/> 272 <Caret Line="838" Column="25" TopLine="816"/> 273 273 </Position3> 274 274 <Position4> 275 <Filename Value=" UProject.pas"/>276 <Caret Line=" 91" Column="49" TopLine="82"/>275 <Filename Value="Analyze\UParser.pas"/> 276 <Caret Line="59" Column="35" TopLine="45"/> 277 277 </Position4> 278 278 <Position5> 279 <Filename Value=" UProject.pas"/>280 <Caret Line=" 92" Column="49" TopLine="82"/>279 <Filename Value="Analyze\UParser.pas"/> 280 <Caret Line="741" Column="38" TopLine="728"/> 281 281 </Position5> 282 282 <Position6> 283 <Filename Value=" UProject.pas"/>284 <Caret Line=" 44" Column="3" TopLine="19"/>283 <Filename Value="Analyze\UParser.pas"/> 284 <Caret Line="732" Column="32" TopLine="719"/> 285 285 </Position6> 286 286 <Position7> 287 <Filename Value=" Forms\UMainForm.pas"/>288 <Caret Line=" 120" Column="40" TopLine="109"/>287 <Filename Value="Analyze\UParser.pas"/> 288 <Caret Line="703" Column="1" TopLine="700"/> 289 289 </Position7> 290 290 <Position8> 291 <Filename Value=" Forms\UMainForm.pas"/>292 <Caret Line=" 122" Column="39" TopLine="106"/>291 <Filename Value="Analyze\UParser.pas"/> 292 <Caret Line="742" Column="36" TopLine="724"/> 293 293 </Position8> 294 294 <Position9> 295 295 <Filename Value="Forms\UMainForm.pas"/> 296 <Caret Line="1 21" Column="22" TopLine="108"/>296 <Caret Line="147" Column="74" TopLine="141"/> 297 297 </Position9> 298 298 <Position10> 299 299 <Filename Value="Forms\UMainForm.pas"/> 300 <Caret Line=" 124" Column="52" TopLine="110"/>300 <Caret Line="58" Column="3" TopLine="66"/> 301 301 </Position10> 302 302 <Position11> 303 303 <Filename Value="Forms\UMainForm.pas"/> 304 <Caret Line=" 123" Column="1" TopLine="110"/>304 <Caret Line="81" Column="1" TopLine="66"/> 305 305 </Position11> 306 306 <Position12> 307 307 <Filename Value="Forms\UMainForm.pas"/> 308 <Caret Line=" 125" Column="1" TopLine="110"/>308 <Caret Line="82" Column="1" TopLine="66"/> 309 309 </Position12> 310 310 <Position13> 311 311 <Filename Value="Forms\UMainForm.pas"/> 312 <Caret Line=" 122" Column="1" TopLine="110"/>312 <Caret Line="83" Column="1" TopLine="66"/> 313 313 </Position13> 314 314 <Position14> 315 <Filename Value=" UProject.pas"/>316 <Caret Line="8 6" Column="1" TopLine="74"/>315 <Filename Value="Forms\UMainForm.pas"/> 316 <Caret Line="84" Column="1" TopLine="66"/> 317 317 </Position14> 318 318 <Position15> 319 <Filename Value=" UProject.pas"/>320 <Caret Line="8 7" Column="1" TopLine="74"/>319 <Filename Value="Forms\UMainForm.pas"/> 320 <Caret Line="85" Column="1" TopLine="66"/> 321 321 </Position15> 322 322 <Position16> 323 323 <Filename Value="UProject.pas"/> 324 <Caret Line=" 86" Column="44" TopLine="74"/>324 <Caret Line="150" Column="1" TopLine="129"/> 325 325 </Position16> 326 326 <Position17> 327 <Filename Value=" Forms\UMainForm.pas"/>328 <Caret Line="1 22" Column="1" TopLine="110"/>327 <Filename Value="UProject.pas"/> 328 <Caret Line="151" Column="1" TopLine="129"/> 329 329 </Position17> 330 330 <Position18> 331 <Filename Value="U Project.pas"/>332 <Caret Line=" 86" Column="1" TopLine="74"/>331 <Filename Value="UCompiler.pas"/> 332 <Caret Line="47" Column="1" TopLine="34"/> 333 333 </Position18> 334 334 <Position19> 335 <Filename Value="U Project.pas"/>336 <Caret Line=" 87" Column="1" TopLine="74"/>335 <Filename Value="UCompiler.pas"/> 336 <Caret Line="48" Column="1" TopLine="34"/> 337 337 </Position19> 338 338 <Position20> 339 <Filename Value="U Project.pas"/>340 <Caret Line=" 89" Column="1" TopLine="74"/>339 <Filename Value="UCompiler.pas"/> 340 <Caret Line="49" Column="1" TopLine="34"/> 341 341 </Position20> 342 342 <Position21> 343 <Filename Value="U Project.pas"/>344 <Caret Line=" 90" Column="1" TopLine="74"/>343 <Filename Value="UCompiler.pas"/> 344 <Caret Line="50" Column="1" TopLine="34"/> 345 345 </Position21> 346 346 <Position22> 347 <Filename Value="U Project.pas"/>348 <Caret Line=" 91" Column="1" TopLine="74"/>347 <Filename Value="UCompiler.pas"/> 348 <Caret Line="51" Column="1" TopLine="34"/> 349 349 </Position22> 350 350 <Position23> 351 <Filename Value="U Project.pas"/>352 <Caret Line=" 92" Column="1" TopLine="74"/>351 <Filename Value="UCompiler.pas"/> 352 <Caret Line="52" Column="1" TopLine="34"/> 353 353 </Position23> 354 354 <Position24> 355 <Filename Value=" UProject.pas"/>356 <Caret Line=" 93" Column="1" TopLine="74"/>355 <Filename Value="Produce\UProducerPascal.pas"/> 356 <Caret Line="154" Column="1" TopLine="141"/> 357 357 </Position24> 358 358 <Position25> 359 <Filename Value=" UProject.pas"/>360 <Caret Line=" 86" Column="1" TopLine="74"/>359 <Filename Value="Produce\UProducerPascal.pas"/> 360 <Caret Line="155" Column="1" TopLine="141"/> 361 361 </Position25> 362 362 <Position26> 363 <Filename Value=" UProject.pas"/>364 <Caret Line=" 99" Column="1" TopLine="78"/>363 <Filename Value="Produce\UProducerPascal.pas"/> 364 <Caret Line="156" Column="1" TopLine="141"/> 365 365 </Position26> 366 366 <Position27> 367 <Filename Value=" UProject.pas"/>368 <Caret Line="8 6" Column="1" TopLine="78"/>367 <Filename Value="Produce\UProducerPascal.pas"/> 368 <Caret Line="85" Column="1" TopLine="72"/> 369 369 </Position27> 370 370 <Position28> 371 <Filename Value=" UProject.pas"/>372 <Caret Line=" 99" Column="1" TopLine="78"/>371 <Filename Value="Produce\UProducerPascal.pas"/> 372 <Caret Line="86" Column="1" TopLine="72"/> 373 373 </Position28> 374 374 <Position29> 375 <Filename Value=" Forms\UMainForm.pas"/>376 <Caret Line=" 123" Column="1" TopLine="110"/>375 <Filename Value="Produce\UProducerPascal.pas"/> 376 <Caret Line="95" Column="1" TopLine="74"/> 377 377 </Position29> 378 378 <Position30> 379 <Filename Value=" Forms\UMainForm.pas"/>380 <Caret Line=" 124" Column="1" TopLine="110"/>379 <Filename Value="Produce\UProducerPascal.pas"/> 380 <Caret Line="86" Column="7" TopLine="75"/> 381 381 </Position30> 382 382 </JumpHistory> … … 419 419 </CompilerOptions> 420 420 <Debugging> 421 <BreakPoints Count="1"> 422 <Item1> 423 <Source Value="Forms\UMainForm.pas"/> 424 <Line Value="81"/> 425 </Item1> 426 </BreakPoints> 421 427 <Exceptions Count="3"> 422 428 <Item1> -
branches/Transpascal/UCompiler.pas
r55 r58 49 49 Parser.SourceCodeText := Source; 50 50 Parser.Init; 51 ProgramCode.Modules.Add(Parser.ParseModule); 51 NewModule := Parser.ParseModule; 52 ProgramCode.Modules.Add(NewModule); 52 53 Producer.Produce(NewModule, ProducedCode); 53 54 end;
Note:
See TracChangeset
for help on using the changeset viewer.