binary selectors ambiguity and space

stéphane ducasse ducasse at iam.unibe.ch
Sun May 14 08:14:23 UTC 2006


Nicolas

do you have a bunch of tests describing the problems and the changes?
This is really important that we document such a behavior.

Stef
On 13 mai 06, at 22:42, nicolas cellier wrote:

> Finally only Scanner>>xBinary need a one line change to allow $- in  
> binary
> selector and preserve the way negated literals are formed without
> ambiguity... Really simple.
>
> You can find it at http://bugs.impara.de/view.php?id=3616
>
> Nicolas
>
>
> Le Samedi 13 Mai 2006 10:05, nicolas cellier a écrit :
>> Let us look inside Parser:
>>
>> $- except as first binary character is forbidden in Scanner>>xBinary
>> Thus '1 +- 2' will scan successive tokens (1) (#+) (#-) (2).
>> This will be parsed with Parser>>messagePart:repeat:
>> Then Parser>>primaryException will gather (#-) (2) into  
>> (LiteralNode value:
>> -2)
>>
>> Without a space  '1+-2' will scan same 4 tokens (1) (#+) (#-) (2),  
>> and
>> result will be the same.
>>
>> However, inside literal quotes, space are significant in current
>> implementation:
>> #(1 - 2) will answer (Array with: 1 with: #- with: 2),
>> #(1-2) will be scanned and parsed into (Array with: 1 with: -2).
>>
>> Concatenating - and 2 as a single token occur in  
>> Scanner>>scanLitVec if and
>> only if char following - is a digit...
>>
>> I know how to change this:
>> - move token concatenation from #scanLitVec to #scanToken
>> - remove #- handling in #primaryExpression
>> - remove limitation in #xBinary
>>
>> But then, this will change semantics of #(1--2) that will be  
>> parsed #(1
>> #'--' 2) instead of #(1 #- -2).
>> We can also make a special handling in xBinary and not groke last  
>> - when
>> immediately followed with a digit, and raise a Warning exception with
>> defaultAction doNothing, but wich could be caught in Parser to  
>> warn user of
>> possible ambiguity if interactive...
>>
>> Thus we would keep most compatibility with current implementation.
>>
>> What do squeakers think of this change ?
>>
>> Nicolas
>
>
>
>




More information about the Squeak-dev mailing list