Created with colorer-take5 library. Type 'ahk'

/* Some strange constructs that must compile and work,
and must be correctly highlighted!
*/

Goto !Code/Ambiguity?

;### Var ambiguity

77 = 7.7   ; Legal but hardly usable
0xBEEF = 48000   ; Not better...
BEEF = 0xBEEF   ; 48879
BEER := 0xBEEF

MsgBox 77=%77%`n0xBEEF=%0xBEEF%`nBEEF=%BEEF%`nBEER=%BEER%
result = Result:

; Variables starting with a number are not usable in expressions...
if (77 = 7.7)
   result = %result%`n77 = 11
if (0xBEEF = 0xBB80)
   result = %result%`n0xBEEF = 0xBB80
if (0xBEEF = 48000)
   result = %result%`n0xBEEF = 48000
if (0xBEEF = 48879)   ;*
   result = %result%`n0xBEEF = 48879

if (BEEF = 0xBEEF)   ;*
   result = %result%`nBEEF = 0xBEEF
if (BEEF = 48000)
   result = %result%`nBEEF = 48000
if (BEEF = 48879)   ;*
   result = %result%`nBEEF = 48879

if (BEER = 0xBEEF)   ;*
   result = %result%`nBEER = 0xBEEF
if (BEER = 48000)
   result = %result%`nBEER = 48000
if (BEER = 48879)   ;*
   result = %result%`nBEER = 48879

MsgBox %result%

!Code/Ambiguity?:
;### Code ambiguity and other constructs hard to highlight

Send = If (foo = bar) ; Not a command, nor a test
NumPad0 = 0 ; Not the start of a hotkey
b := true
If (F(5, 4 + 1)   ; Not the end of the If expression
      or b)
   Gosub MsgBox
ExitApp

NumPad0::
MsgBox: ; Not a command...
   MsgBox : %Send% ; Not a label
   MsgBox (foo)   ; Not a function call
   Send :: NumPad0 ; Not a hotkey
   If !b
      Return ; Folding of label goes to next return, not this one!
   Send:=42 ; Not a label
   MsgBox => Result ; Not a MsgBox command!
   If b = (   ; Not the start of an expression
      F(5, 6)
Return

F(a
, b)   ; Not a function call!
; Legal

{
   %a% := "foo"
   x%b% = bar
   If ((a)&&(b))
      x:=a
   If (a =
(
x
)
and b)
      x -= a / 2
   Return a = b
}