zero-plusplus / vscode-autohotkey-debug

https://marketplace.visualstudio.com/items?itemName=zero-plusplus.vscode-autohotkey-debug
MIT License
50 stars 4 forks source link

Change the syntax of debug directive #275

Open zero-plusplus opened 1 year ago

zero-plusplus commented 1 year ago

The syntax of the debug directive was not the specification we originally had in mind. The current specification was conceived to somehow make it feasible at a time when there was no knowledge of the expression evaluation process.

The original idea was to have the same syntax as the compiler directives.

Since this is a destructive change, I will change it at this time of a major update.

The changes are as follows.

; Newline after output
; old
; @Debug-Output(A_ThisFunc == "A") => {A_ThisFunc}
; new
; @Debug-Output A_ThisFunc == "A", {A_ThisFunc}
; No newline after output
; old
; @Debug-Output(A_ThisFunc == "A") -> {A_ThisFunc}
; new
; @Debug-Output A_ThisFunc == "A", {A_ThisFunc}, false
; Do not trim blanks before
; old
; @Debug-Output(A_ThisFunc == "A") ->| {A_ThisFunc}
; new
; @Debug-Output A_ThisFunc == "A", {" " . A_ThisFunc}, false

Under the new specification, it will no longer be possible to specify the hit condition. However, this is not a problem, as hit conditions can be reproduced in the new evaluation process as follows.

; @Debug-Output GetMeta("hitCount") == 5, message

;  Modulo operations, which were supported only in hit conditions in the previous specification, are also available
; @Debug-Output Mod(GetMeta("hitCount"), 2), message
; @Debug-Output GetMeta("hitCount") == 5, message

GROUPPING in DebugOutput specifies the following keywords to the log in the new syntax

; @Debug-Output Group \{{:start:}items1\nitems2\nChild \{{:startCollapsed:}item1{:end:}}{:end:}}

; The following is the output of the log above
; Group {
;   item1
;   item2
;   Child {
;     * item1
;   }
; }

; The following example is an above example separated by each line.
; @Debug-Output Group \{
; @Debug-Output {:start:}
; @Debug-Output items1
; @Debug-Output items2
; @Debug-Output Child \{
; @Debug-Output {:startCollapsed:}
; @Debug-Output items1
; @Debug-Output {:end:}
; @Debug-Output {:end:}
; @Debug-Output }
zero-plusplus commented 1 year ago

This change was intended to be compatible with compiler directives, but has the fatal problem that all commas need to be escaped.

I therefore focused on the #If directive. This directive accepts a single expression and does not require escaping commas.

By viewing the conventional syntax as a special expression, the following can be used to preserve a minimum of usability. However, it is not fully compatible.

; Note that a space or comma is required after the directive name
; @Debug-Output => abc {"edf"}
; @Debug-Output (a == b)[=3] => abc {"edf"}
; @Debug-Output [=3] => abc {"edf"}
; @Debug-Output, (a == b)[=3] => abc {"edf"}

; If no condition is specified, the output operator (=>) can be omitted, but must be escaped as '=' if it starts with '`='
; @Debug-Output, abc {"edf"}

; The following means the same
; @Debug-Output, => => abc {"edf"}
; @Debug-Output, `=> abc {"edf"}