1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
| ;прога работает только с АНСИ, поэтому надо переключить прогу с юникода ; все пути к компилятору должны быть только латинскими букавками, иначе неработает прога Debug "прога работает только с АНСИ, поэтому надо переключить прогу(компилятор) с юникода" CompilerIf #PB_Compiler_Unicode CompilerError "Please turn off compiler option 'Create unicode executable'" CompilerEndIf EnableExplicit #Compiler = #PB_Compiler_Home+"compilers\pbcompiler.exe" Debug #Compiler If ReadFile(0, #Compiler)=0 MessageRequester("Err", "not found PureBasic Compiler - 'compilers\pbcompiler.exe' ") End EndIf Procedure StartCompiler() ProcedureReturn RunProgram(#Compiler,"/STANDBY","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide) EndProcedure Procedure StopCompiler(compiler) WriteProgramStringN(compiler, "END") WaitProgram(compiler,5000) CloseProgram(compiler) EndProcedure Procedure SendCompilerCommand(compiler,command$) If ProgramRunning(compiler) WriteProgramStringN(compiler, command$) EndIf EndProcedure Procedure.s GetCompilerOutput(compiler) If AvailableProgramOutput(compiler) ProcedureReturn ReadProgramString(compiler) EndIf EndProcedure Procedure FillList(compiler,List out.s(),space=0) Protected out$ Protected space$=Space(space) While out$<>"OUTPUT"+#TAB$+"COMPLETE" And Left(out$,5)<>"ERROR" out$=GetCompilerOutput(compiler) If out$ And out$<>"OUTPUT"+#TAB$+"COMPLETE" And Left(out$,5)<>"ERROR" And FindString("0123456789",Mid(out$,1,1))=0 AddElement(out()) out()=space$+out$ EndIf Wend EndProcedure Procedure FillConstantList(compiler,List out.s(),space=0) Protected out$ Protected space$=Space(space) While out$<>"OUTPUT"+#TAB$+"COMPLETE" And Left(out$,5)<>"ERROR" out$=GetCompilerOutput(compiler) If out$<>"" And out$<>"OUTPUT"+#TAB$+"COMPLETE" And Left(out$,5)<>"ERROR" And FindString("0123456789",Mid(out$,2,1))=0 If FindString("01",Mid(out$,1,1)) out$ = "#"+Mid(out$,2,Len(out$)-1) out$ = ReplaceString(out$,#TAB$," = ") out$ = ReplaceString(out$,"# = ","#") ElseIf FindString("2",Mid(out$,1,1)) Protected i, found_non_printable = #False Protected oldout$ = out$ Protected sconst_value$ = StringField(oldout$,3,Chr(9)) out$ = "#"+StringField(oldout$,2,#TAB$) For i = 1 To Len(sconst_value$) If Asc(Mid(sconst_value$,i)) < 32 Or Asc(Mid(sconst_value$,i)) > 126 found_non_printable = #True EndIf Next i If out$ = "#TAB$" out$ + " = Chr(9)" ElseIf out$ = "#HT$" out$ + " = Chr(9)" ElseIf out$ = "#CRLF$" out$ + " = Chr(13) + Chr(10)" ElseIf out$ = "#LFCR$" out$ + " = Chr(10) + Chr(13)" ElseIf out$ = "#LF$" out$ + " = Chr(10)" ElseIf out$ = "#CR$" out$ + " = Chr(13)" ElseIf out$ = "#DOUBLEQUOTE$" out$ + " = Chr(34)" ElseIf out$ = "#DQUOTE$" out$ + " = Chr(34)" ElseIf found_non_printable = #False out$ + " = " + #DQUOTE$ + StringField(oldout$,3,#TAB$) + #DQUOTE$ Else out$ + " =" Protected temp$ = StringField(oldout$,3,#TAB$) For i = 0 To Len(sconst_value$)-1 out$ + " Chr("+Str(PeekB(@temp$+(SizeOf(Character)))) + ") +" Next EndIf out$ = RTrim(out$,"+") out$ = Trim(out$) Else Debug out$ EndIf out$ = Trim(out$) If out$ AddElement(out()) out()=space$+out$ EndIf EndIf Wend EndProcedure Procedure GetStructureList(compiler,List out.s()) If ProgramRunning(compiler) SendCompilerCommand(compiler,"STRUCTURELIST") FillList(compiler,out()) EndIf EndProcedure Procedure GetProcedureList(compiler,List out.s()) If ProgramRunning(compiler) SendCompilerCommand(compiler,"FUNCTIONLIST") FillList(compiler,out()) EndIf EndProcedure Procedure GetConstantsList(compiler,List out.s()) If ProgramRunning(compiler) SendCompilerCommand(compiler,"CONSTANTLIST") FillConstantList(compiler,out()) EndIf EndProcedure Procedure GetInterfaceList(compiler,List out.s()) If ProgramRunning(compiler) SendCompilerCommand(compiler,"INTERFACELIST") FillList(compiler,out()) EndIf EndProcedure Procedure GetStructureInfo(compiler,struct$,List out.s()) If ProgramRunning(compiler) SendCompilerCommand(compiler,"STRUCTURE"+#TAB$+struct$) FillList(compiler,out(),4) EndIf EndProcedure Procedure GetInterfaceInfo(compiler,interf$,List out.s()) If ProgramRunning(compiler) SendCompilerCommand(compiler,"INTERFACE"+#TAB$+interf$) FillList(compiler,out(),4) EndIf EndProcedure Procedure WaitCompilerReady(compiler) Protected out$ While out$<>"READY" And Left(out$,5)<>"ERROR" out$ = GetCompilerOutput(compiler) If out$ Debug out$ EndIf Wend EndProcedure Define pb, out$ NewList constants.s() NewList structures.s() NewList procedures.s() NewList interfaces.s() NewList structureInfo.s() NewList interfaceInfo.s() pb = StartCompiler() Debug "pb = StartCompiler()="+Str(pb) If pb Debug "WaitCompilerReady(pb) (ожидаем запуска компилятора)" WaitCompilerReady(pb) Debug "go go, Ура запустился, короче поехали искать списки" GetStructureList(pb,structures()) Debug "found "+Str(ListSize(structures()))+" structures" GetProcedureList(pb,procedures()) Debug "found "+Str(ListSize(procedures()))+" procedures" GetConstantsList(pb,constants()) Debug "found "+Str(ListSize(constants()))+" constants" SortList(constants(),#PB_Sort_Ascending|#PB_Sort_NoCase) GetInterfaceList(pb,interfaces()) Debug "found "+Str(ListSize(interfaces()))+" interfaces" ClearList(structureInfo()) Debug "ClearList(structureInfo())" ForEach structures() AddElement(structureInfo()) structureInfo()="Structure "+structures() GetStructureInfo(pb,structures(),structureInfo()) AddElement(structureInfo()) structureInfo()="EndStructure" AddElement(structureInfo()) structureInfo()="" Next ClearList(interfaceInfo()) Debug "ClearList(interfaceInfo())" ForEach interfaces() AddElement(interfaceInfo()) interfaceInfo()="Interface "+interfaces() GetInterfaceInfo(pb,interfaces(),interfaceInfo()) AddElement(interfaceInfo()) interfaceInfo()="EndInterface" AddElement(interfaceInfo()) interfaceInfo()="" Next Debug "" Debug "SAVE resultat(сохраняем результаты)" If CreateFile(0,"c:\Structures.pb") Debug "create Structures.pb" ForEach structureInfo() WriteStringN(0,structureInfo()) Next CloseFile(0) Else Debug "no create Structures.pb" EndIf If CreateFile(0,"c:\Interfaces.pb") Debug "create Interfaces.pb" ForEach interfaceInfo() WriteStringN(0,interfaceInfo()) Next CloseFile(0) Else Debug "no create Interfaces.pb" EndIf If CreateFile(0,"c:\Constants.pb") Debug "create Constants.pb" ForEach constants() WriteStringN(0,constants()) Next CloseFile(0) Else Debug "no create Constants.pb" EndIf If CreateFile(0,"c:\Procedures.pb") Debug "create Procedures.pb" ForEach procedures() WriteStringN(0,procedures()) Next CloseFile(0) Else Debug "no create Procedures.pb" EndIf StopCompiler(pb) Debug "END. Shearh in directory - 'c:\'.(результат на диске 'c:\' в файлах:Structures.pb,Interfaces.pb,Constants.pb,Procedures.pb)" Else Debug "No StartCompiler, Error(почемуто компилятор незапустился)" EndIf |