• 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: Phil Stokes <email@hidden>
  • Date: Sun, 17 Jan 2016 18:12:00 +0700

On 17 Jan 2016, at 16:22, Chris Page <email@hidden> wrote:

Short of AI, how do you propose detecting this case? 

It doesn’t need AI, Chris, or even a lot of ‘I’ ; I did it myself in my now defunct proto-app “DisplayDroid” for which I wrote a “pre-compiler” to apply various rules before invoking OSAScript’s compileAndReturnError. I’m an amateur, and not a very good one at that, so I find it hard to believe this strikes an Apple programmer as in the realms of “AI”.

The particular case mentioned is easily solved as the compiler (or pre-compiler in my app’s case) can be taught to recognise that after a “tell application" there must be a closed, quoted string before a new line (application names don’t have new line characters in them). 

In the code I wrote for my editor, I combined scanner searches looking for AS keywords on each line, and then a bunch of  conditionals using the grammar rules of the AS keywords to figure out and highlight various errors. It wasn’t perfect, and nowhere near complete, but with a bit more development none of the difficulties I could see were theoretically insurmountable. It just needed more rules adding, and I would have added them if the app itself (of which the AS editor was only a part)
had garnered any interest. Alas, that was not the case. 

Scripts containing “run script” I think were my biggest stumbling block. I think because I was parsing the user’s script line by line. I know there’s another way of doing (the way it’s done in Script Debugger), but I never figured out how to do that (Shane or has or someone pointed me to a paper by William Cook* which briefly mentions two different approaches to writing an AS debugger, which I also had a crack at. I basically took the first approach for both my pre-compiler and my debugger, of breaking the user’s script down line by line, checking it and compiling it before putting it all back together again). If I ever get the luxury of time on my hands, I still intend to write my own full AS Editor at some point, but I’d rather you guys just improved the one we’ve got, cos that’s the only reason I want to do it.


Do you know of any compilers for any other languages that could do so?

I’m not sure about compilers**, but there’s text editors galore that do basic things like quotation balancing. Xcode’s CodeSense (or whatever it’s called these days) does a great job of the sort of thing I’m talking about as do many other IDE’s. I’m not necessarily asking for anything that sophisticated, but some sort of static analyser** doesn’t seem to be an out-of-this-world-in-the-realms-of-science-fiction request for a language as venerable as AppleScript. Does it?




Best



Phil



*Who, by the way, states himself that “…obscure error messages continue to be one of the biggest impediments to using AppleScript”, and that was in 2006. Ref: Cook, W (2006) ‘AppleScript’. http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf


**As an untrained, fairly inexperienced and generally sloppy programmer, I tend to throw around technical terms incorrectly, so whether or not it’s the compiler/static analyser or some other part of the program that does the work I’m talking about is not really the issue (though it may confuse the way I state the issue). I basically want an AS Editor which does a better job at helping users determine and fix errors before runtime (and during if possible, but I know that asking for a debugger probably is asking for too much).



 
 _______________________________________________
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: Chris Page <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>)
 >Re: Grammar Police in OS X 10.11 (From: Chris Page <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