This has topic brought to my attention a more general inconsistency between built-in commands and other commands. Standalone actions which start with a word are currently handled in this order:
- Function-calls which end the line with ')' (due to the way function definitions are handled)
- Assignments, dot (x.y, x.y := z, x.y(), etc.)
- Built-in commands
- Post-increment/decrement (i++)
- Ternary
- Function calls, calls to object properties (x[]), expressions that begin the line with '('
- Anything that could be a user-defined command (since some functions may be defined later in the script)
I think that if it looks like a command, it should be a handled as a command -- I'll be changing user-defined (and undefined) commands to be interpreted the same as built-in commands.
Ternary is recognized in two separate cases (after handling built-in commands):
- The first non-whitespace character after the name is '?'.
- The first non-whitespace character after the name is an "expression" character, and the line contains '?' with ':' somewhere to the right of it.
The second case is a very rough check, but in v1 that's fine since the only alternative is to treat the line as an error. I am currently considering two options:
- Make #1 above the same precedence as assignment, so cmd ? ... is always an expression, but make #2 lower precedence than commands (since it's a rough check).
- Make ternary lower precedence than commands, so cmd ? ... is always a command.
For both options,
cmd,? is always a command and
w+x ? y : z is always an expression (because there's no space after
w). Also, any line beginning with
( and containing
) is an expression.
There are some cases which are currently handled incorrectly in both versions of AutoHotkey:
Code: Select all
msgboz, (This is incorrectly assumed to be a function call, so the typo is not reported)
msgobx, [As above]
foo,++ ; v1 says: "+=" requires that parameter #2 be non-blank.
foo,? ; Treated as an expression. v2 complains about the missing ':'.
Basically, the comma is inappropriately ignored.