Advertisement
AZJIO

PECMD analysis HELP

Feb 28th, 2018
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.03 KB | None | 0 0
  1.  
  2. $sText = FileRead(@ScriptDir & '\парсинг.txt')
  3. $aArray=StringRegExp($sText, '\┃\h+\│CMD \│''([A-Za-z]+?)''(?s)(.+?)\r\n┣━+?┿━+?┿━+?┫', 3)
  4. ; $html = ''
  5. $header= _
  6. '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' & @CRLF & _
  7. '<html>' & @CRLF & _
  8. '<head>' & @CRLF & _
  9. '<title>Справка</title>' & @CRLF & _
  10. '<meta content="text/html; charset=windows-1251" http-equiv="Content-Type">' & @CRLF & _
  11. '<link type="text/css" rel="stylesheet" href="styles.css">' & @CRLF & _
  12. '</head>'
  13. ; MsgBox(0, "Сообщение", $text)
  14. $html = $header
  15.  
  16. $s=UBound($aArray)
  17. For $i = 0 To $s-1 Step 2
  18.     $html0=$header
  19.     $syntax=''
  20.     $description=''
  21.     $parametr=''
  22.     $Example=''
  23.     $Notes=''
  24.     $name = $aArray[$i]
  25.     $body = $aArray[$i+1]
  26.     ; $tmp=StringRegExp($body, '\┃\h+\│FORM\│(.+?)(?=\h+\r\n)', 2)
  27.     $tmp=StringRegExp($body, '(?s)\┃\h+\│FORM\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
  28.     If Not @error Then
  29.         $syntax=_Del($tmp)
  30.     EndIf
  31.     $tmp=StringRegExp($body, '(?s)\┃(?:' & $name & ')?\h+\│Функция\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
  32.     If Not @error Then
  33.         $description=_Del($tmp)
  34.     EndIf
  35.     $tmp=StringRegExp($body, '(?s)\┃(?:' & $name & ')?\h+\│PARA\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
  36.     If Not @error Then
  37.         $parametr=_Del($tmp)
  38.     EndIf
  39.     $tmp=StringRegExp($body, '(?s)\┃\h+\│Пример\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
  40.     If Not @error Then
  41.         $Example=_Del($tmp)
  42.     EndIf
  43.     $tmp=StringRegExp($body, '(?s)\┃\h+\│REM\h+\│(.+?)(\r\n┣━+?┿━+?┿━+?┫\s*)', 2)
  44.     If Not @error Then
  45.         $Notes=_Del($tmp)
  46.     EndIf
  47.     $html0 &= @CRLF & '<h1>' & $name & '</h1>' & @CRLF
  48.     If $syntax Then $html0 &= @CRLF & '<h3>Синтаксис</h3>' &  @CRLF & '<pre class="codeheader">' & $syntax & '</pre>'
  49.     If $description Then $html0 &=  @CRLF & '<h3>Описание</h3>' &  @CRLF & '<pre class="funcdesc">' & $description & '</pre>'
  50.     If $parametr Then $html0 &=  @CRLF & '<h3>Параметры</h3>' &  @CRLF & '<pre>' & $parametr & '</pre>'
  51.     If $Example Then $html0 &=  @CRLF & '<h3>Пример</h3>' &  @CRLF & '<pre class="codebox">' & $Example & '</pre>'
  52.     If $Notes Then $html0 &=  @CRLF & '<h3>Примечания</h3>' &  @CRLF & '<pre>' & $Notes & '</pre>'
  53.     $html0 &=  @CRLF & '<h3>Остатки</h3>' &  @CRLF & '<pre>' & $body & '</pre>'
  54.     $hFile = FileOpen(@ScriptDir & '\html\' & $name & '.htm', 2)
  55.     FileWrite($hFile, $html0 &  @CRLF & '<br /><br /><br /><br /></body></html>')
  56.     FileClose($hFile)
  57.     $html &= $html0
  58. Next
  59. $html &=  @CRLF & '<br /><br /><br /><br /></body></html>'
  60.  
  61. $hFile = FileOpen(@ScriptDir & '\file.htm', 2)
  62. FileWrite($hFile, $html)
  63. FileClose($hFile)
  64. MsgBox(0, 'Сообщение', 'Готово')
  65.  
  66.  
  67. Func _Del($tmp)
  68.     $res = $tmp[1]
  69.     ; $body = StringReplace($body, $tmp, '') ; удаляем найденную строку
  70.     $body = StringReplace($body, $tmp[0], '') ; удаляем найденое
  71.     $res=StringRegExpReplace($res, '(?:\│|\┃)\h+(?=\│)', '')
  72.     $res = StringReplace($res, @CRLF & '|', @CRLF)
  73.     Return $res
  74. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement