mmikeww / AHK-v2-script-converter

AHK v1 -> v2 script converter
https://autohotkey.com/boards/viewtopic.php?f=6&t=25100
The Unlicense
580 stars 44 forks source link

Contiuation strips or places comments in wrong spot #296

Open Banaanae opened 1 month ago

Banaanae commented 1 month ago

V1:

var := DllCall("Func"
     , "Str", "ABC" ; Comment
     , "Str", "123"   ; Comment
     , "Str", "DEF") ;Comment

hCtrl := DllCall("CreateWindowEx"
      , "Uint", 0x200        ; WS_EX_CLIENTEDGE
      , "str",  "HiEdit"     ; ClassName
      , "str",  ""           ; WindowName
      , "Uint", WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | hStyle
      , "int",  X            ; Left
      , "int",  Y            ; Top
      , "int",  W            ; Width
      , "int",  H            ; Height
      , "Uint", HParent      ; hWndParent
      , "Uint", MODULEID     ; hMenu
      , "Uint", 0            ; hInstance
      , "Uint", 0, "Uint")

V2 (Converted):

var := DllCall("Func"
     , "Str", "ABC"
     , "Str", "123"
     , "Str", "DEF")

hCtrl := DllCall("CreateWindowEx"

V2 (Expected):

var := DllCall("Func"
     , "Str", "ABC" ; Comment
     , "Str", "123"   ; Comment
     , "Str", "DEF") ;Comment

hCtrl := DllCall("CreateWindowEx"
      , "Uint", 0x200        ; WS_EX_CLIENTEDGE
      , "str",  "HiEdit"     ; ClassName
      , "str",  ""           ; WindowName
      , "Uint", WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | hStyle
      , "int",  X            ; Left
      , "int",  Y            ; Top
      , "int",  W            ; Width
      , "int",  H            ; Height
      , "Uint", HParent      ; hWndParent
      , "Uint", MODULEID     ; hMenu
      , "Uint", 0            ; hInstance
      , "Uint", 0, "Uint")

Two examples, second one came when trying to reproduce first Need to look into it further Example 1: Comments are stripped

When return variables are removed comments are still missing

Banaanae commented 1 month ago

, "str", "" causes issues in the second example

Banaanae commented 3 weeks ago

Issues with large portions of code going missing are now fixed

Comments in continuations face 1 of 2 issues

var := "line 1" ; comment 1
    . "line 2" ; comment 2
; -> converts to ->
var := "line 1"
    . "line 2" ; comment 1

The converter treats above as one line (rather than 2, this is intended behaviour) Fix would likely be

; Store comment in map
; line comment is on: comment

; restore once line conversion is done

Same issue with function continuations but they are stripped instead Maybe same fix as above?