Re: BUG: AppleScript compilation problems
Re: BUG: AppleScript compilation problems
- Subject: Re: BUG: AppleScript compilation problems
- From: Steven Angier <email@hidden>
- Date: Mon, 21 Apr 2003 10:01:23 +1000
On 19/4/03 5:36 AM, "Chris Espinosa" <email@hidden> wrote:
>
>> Here are a couple of bugs involving the compiling of comments in
>
>> AppleScript:
>
>>
>
>>
>
>> 1. A block comment can't contain an odd number of double-quote characters:
>
>>
>
>> (*
>
>> "
>
>> *)
>
>>
>
>> --> compilation error
>
>
>
> This is deliberate. Because AS allows you to nest block comments, it does
>
> some parsing of the comment's contents. By introducing the beginning of a
>
> string, its going to keep going until it sees the end quote.
>
>
>
> This is explained in the AppleScript language guide (page 26 in my original
>
> hardcopy version).
>
>
>
>> I can understand how this could happen because, when parsing source code,
>
>> something has to take precedence. In the previous case, a literal string
>
>> takes precedence over a block comment, though in the next case a single-line
>
>> comment takes precedence over a literal string:
>
>>
>
>> --"
>
>>
>
>> --> compiles OK
>
>
>
> Right, because a line comment simply consumes everything after it on the
>
> line and does no parsing of the comment contents.
>
>
This was introduced in AppleScript 1.1 (first reported 10/22/93) and , as
>
Mark says, it's a regrettable side-effect of the ability of block comments
>
to comment out code. You're both correct in that end-of-line comments
>
ignore superficial syntax but block comments obey it.
Thanks Chris (and Mark) for your replies. Having just written code that
parses AppleScript source code for literal strings and comments, I can
understand how this happened.
However, having solved these problems myself, I can also say that it is a
pretty simple task to track whether a given character (e.g. a double quote)
is within a block comment or not, and treat it accordingly.
It may be a regrettable side-effect, but it was certainly easily avoidable.
Steven Angier
Macscript.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.