• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Grammar Police in OS X 10.11
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grammar Police in OS X 10.11


  • Subject: Re: Grammar Police in OS X 10.11
  • From: Chris Page <email@hidden>
  • Date: Sun, 17 Jan 2016 01:22:20 -0800


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.

Please file bug reports about any error messages that could be improved: https://developer.apple.com/bug-reporting/

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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Grammar Police in OS X 10.11
      • From: Phil Stokes <email@hidden>
References: 
 >Re: Grammar Police in OS X 10.11 (From: Nigel Garvey <email@hidden>)
 >Re: Grammar Police in OS X 10.11 (From: Phil Stokes <email@hidden>)
 >Re: Grammar Police in OS X 10.11 (From: Chris Page <email@hidden>)
 >Re: Grammar Police in OS X 10.11 (From: Phil Stokes <email@hidden>)

  • Prev by Date: Re: Why Doesn't This Script.app Quit?
  • Next by Date: Re: Why Doesn't This Script.app Quit?
  • Previous by thread: Re: Grammar Police in OS X 10.11
  • Next by thread: Re: Grammar Police in OS X 10.11
  • Index(es):
    • Date
    • Thread