On Jan 15, 2016, at 5:15 AM, Phil Stokes < email@hidden> wrote:
Well, it was sort of tongue-in-cheek, Chris, and I’m not here to disparage your work, but even so after 20+ years we still can’t get anything better than this:
tell app "Xcode set x to 1 set y to 2 end
—> Syntax Error Expected “”” but found end of script
Couldn't we even get the cursor or highlight on the offending line?
By default, syntax-error reporting is automatically generated from the grammar. It's likely that this error message (and text selection range) was chosen from among several alternatives available to the parser, and it probably just needs a little manual intervention to choose a better error report.
Here’s the same error (missing end quote on line 1) on a previously compiled script, but compare what we get now from the compiler when we try to compile or run again after making the error:
tell application "Xcode tell source document 1 set {a, b} to selected character range set c to contents set d to text a thru b of c --my findAll(d, "== NS") --returns the offset of each occurrence my replaceString(d, "=/", "= / ") -- replace every occurence of $1 with $2 in $0
--when you're done changing, you need to copy back to source doc set formattedText to c set contents to formattedText end tell end tell
Syntax Error Expected _expression_ but found “=”. (highlights the second ‘=‘ character on Line 6 - yeah, you’ll have to count cos there’s no line numbers in ASE either… :p)
I understand why it does that (it sees the second quote mark on Line 6 as the end of a string, and then see’s an error after that), but that doesn’t change the fact that it’s not just unhelpful, it’s thoroughly misleading.
Short of AI, how do you propose detecting this case? Do you know of any compilers for any other languages that could do so? Error reporting in the AS compiler is like a blunt hammer, and while experience ameliorates the problem for the seasoned hand, I expect for most people coming to AS fresh, it’s the biggest stumbling block. I know when I first started out just getting a script to compile was a major triumph. The compiler could do a great deal more here to ease the learning curve.
Run-time error reporting could also do with a serious makeover, but I’d be happy just to see some improvements at compile time (mutter, mutter and mutter line numbers, mutter, breakpoints, variable introspection, mutter mutter...).
It will never hurt to file reports requesting improvements. The presence of reports is taken into account when allocating resources and prioritizing work.
-- Chris Page The other, other AppleScript Chris
|