The Trunk: Compiler-nice.120.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler-nice.120.mcz

commits-2
Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.120.mcz

==================== Summary ====================

Name: Compiler-nice.120
Author: nice
Time: 23 February 2010, 5:14:44.049 pm
UUID: 9429cc05-281b-484e-94c2-bd0baf4f5230
Ancestors: Compiler-nice.119

Authorize - at any position in binary selectors (like VW 7.7)
See http://bugs.squeak.org/view.php?id=3616
Address the problem of compiling 1@-2 with following strategy:

If compiler is non interactive, then compile with backward compatibility 1 @ (-2).
If compiler is interactive, propose a menu to disambiguate and insert a proper space.
1@ -2 -> MessageSend receiver: 1 selector: #'@' argument: -2
1@- 2 -> MessageSend receiver: 1 selector: #'@-' argument: 2

Warning: Squeak did understand (1@-   2) as (1 @ (-2))....
I didn't do anything to support this vicious Squeakism, and by now the semantics are change.


=============== Diff against Compiler-nice.119 ===============

Item was changed:
+ ----- Method: ParserNotification>>openMenuIn: (in category 'handling') -----
- ----- Method: ParserNotification>>openMenuIn: (in category 'as yet unclassified') -----
  openMenuIn: aBlock
  self subclassResponsibility!

Item was changed:
+ ----- Method: UndeclaredVariable class>>signalFor:name:inRange: (in category 'instance creation') -----
- ----- Method: UndeclaredVariable class>>signalFor:name:inRange: (in category 'as yet unclassified') -----
  signalFor: aParser name: aString inRange: anInterval
  ^ (self new setParser: aParser name: aString range: anInterval) signal!

Item was added:
+ ----- Method: AmbiguousSelector>>openMenuIn: (in category 'handling') -----
+ openMenuIn: aBlock
+ "Ask the user which selector to choose.
+ Answer the choosen selector or nil if cancellation is requested."
+
+ | labels actions lines caption choice |
+ labels := {
+ 'selector is ' , (name copyFrom: 1 to: name size - 1) , ' argument is negative'.
+ 'selector is ' , name , ' argument is positive'.
+ 'cancel'}.
+ actions := {
+ name copyReplaceFrom: name size to: name size - 1 with: ' '.
+ name copyReplaceFrom: name size + 1 to: name size with: ' '.
+ nil.
+ }.
+ lines := {2}.
+ caption := 'Ambiguous selector: ' , name , ' please correct, or cancel:'.
+ choice := aBlock value: labels value: lines value: caption.
+ self resume: (actions at: choice ifAbsent: [nil])!

Item was added:
+ ----- Method: Parser>>ambiguousSelector:inRange: (in category 'error correction') -----
+ ambiguousSelector: aString inRange: anInterval
+ | correctedSelector userSelection |
+
+ self interactive ifFalse: [
+ "In non interactive mode, compile with backward comapatibility: $- is part of literal argument"
+ token := token asSymbol.
+ ^self].
+
+ "handle the text selection"
+ userSelection := requestor selectionInterval.
+ requestor selectFrom: anInterval first to: anInterval last.
+ requestor select.
+
+ "Build the menu with alternatives"
+ correctedSelector := AmbiguousSelector
+ signalName: aString
+ inRange: anInterval.
+ correctedSelector ifNil: [^self fail].
+
+ "Execute the selected action"
+ self substituteWord: correctedSelector wordInterval: anInterval offset: 0.
+ requestor deselect.
+ requestor selectInvisiblyFrom: userSelection first to: userSelection last + 1.
+ token := (correctedSelector readStream upTo: Character space) asSymbol!

Item was changed:
  ----- Method: Scanner>>xBinary (in category 'multi-character scans') -----
  xBinary
 
+ | startOfToken |
  tokenType := #binary.
+ startOfToken := mark.
  token := String with: self step.
+ [(self typeTableAt: hereChar) == #xBinary] whileTrue:
+ [(hereChar == $- and: [(self typeTableAt: aheadChar) == #xDigit])
+ ifTrue: [^self ambiguousSelector: (token , '-')
+ inRange: (startOfToken to: source position - 1).].
+ token := token, (String with: self step)].
- [hereChar ~~ $- and: [(self typeTableAt: hereChar) == #xBinary]] whileTrue:
- [token := token, (String with: self step)].
  token := token asSymbol!

Item was changed:
+ ----- Method: ParserNotification>>setName: (in category 'private') -----
- ----- Method: ParserNotification>>setName: (in category 'as yet unclassified') -----
  setName: aString
  name := aString!

Item was added:
+ ParserNotification subclass: #AmbiguousSelector
+ instanceVariableNames: 'interval'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Compiler-Exceptions'!
+
+ !AmbiguousSelector commentStamp: 'nice 2/23/2010 15:40' prior: 0!
+ An AmbiguousSelector is a notification produced by the Scanner/Parser/Compiler when encountering this ambiguous construct:
+
+ 1@-2
+
+ Upper expression can be interpreted both
+ 1 @ -2 (regular st-80 and former Squeak syntax, the minus is attached to the literal number)
+ 1 @- 2 (extended binary selector, the minus sign is allowed at any position and thus part of the binary selector)
+ !

Item was added:
+ ----- Method: AmbiguousSelector classSide>>signalName:inRange: (in category 'instance creation') -----
+ signalName: aString inRange: anInterval
+ ^ (self new setName: aString range: anInterval) signal!

Item was added:
+ ----- Method: AmbiguousSelector>>setName:range: (in category 'private') -----
+ setName: aString range: anInterval
+ name := aString.
+ interval := anInterval!