binary selectors ambiguity and space
ducasse at iam.unibe.ch
Sun May 14 08:14:23 UTC 2006
do you have a bunch of tests describing the problems and the changes?
This is really important that we document such a behavior.
On 13 mai 06, at 22:42, nicolas cellier wrote:
> Finally only Scanner>>xBinary need a one line change to allow $- in
> 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
> 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:
>> Without a space '1+-2' will scan same 4 tokens (1) (#+) (#-) (2),
>> result will be the same.
>> However, inside literal quotes, space are significant in current
>> #(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 ?
More information about the Squeak-dev