[squeak-dev] The Trunk: Compiler-nice.219.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Oct 24 16:52:42 UTC 2011
Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.219.mcz
==================== Summary ====================
Name: Compiler-nice.219
Author: nice
Time: 24 October 2011, 6:52:05.789 pm
UUID: 871ffcae-841f-194e-ab14-0a7a493df385
Ancestors: Compiler-nice.218
Let a binary selector be composed of vertical bars.
Since st80, such selector were not composed at scan time because of ambiguity with empty temporaries spec || and latter with temporaries in a block of arity >0 like ^[:e|| tmp | tmp := e]
But a hack in the Parser did authorize a single #| as a valid binary.
Since
- we can unambiguously extend this hack easily,
- ANSI seems to tell it's a valid binary character in a binary selector,
- I never saw any grammar definition explicitely forbidding this,
Let's just do it.
=============== Diff against Compiler-nice.218 ===============
Item was changed:
----- Method: Parser>>messagePart:repeat: (in category 'expression types') -----
messagePart: level repeat: repeat
| start receiver selector args precedence words keywordStart |
[receiver := parseNode.
(hereType == #keyword and: [level >= 3])
ifTrue:
[start := self startOfNextToken.
selector := WriteStream on: (String new: 32).
args := OrderedCollection new.
words := OrderedCollection new.
[hereType == #keyword]
whileTrue:
[keywordStart := self startOfNextToken + requestorOffset.
selector nextPutAll: self advance.
words addLast: (keywordStart to: self endOfLastToken + requestorOffset).
self primaryExpression ifFalse: [^self expected: 'Argument'].
self messagePart: 2 repeat: true.
args addLast: parseNode].
(Symbol hasInterned: selector contents ifTrue: [ :sym | selector := sym])
ifFalse: [ selector := self correctSelector: selector contents
wordIntervals: words
exprInterval: (start to: self endOfLastToken)
ifAbort: [ ^ self fail ] ].
precedence := 3]
+ ifFalse: [
+ (level >= 2 and: [hereType == #verticalBar]) ifTrue: [self transformAVerticalBarIntoABinarySelector].
+ (hereType == #binary and: [level >= 2])
- ifFalse: [((hereType == #binary or: [hereType == #verticalBar])
- and: [level >= 2])
ifTrue:
[start := self startOfNextToken.
selector := self advance asOctetString asSymbol.
self primaryExpression ifFalse: [^self expected: 'Argument'].
self messagePart: 1 repeat: true.
args := Array with: parseNode.
precedence := 2]
ifFalse: [hereType == #word
ifTrue:
[start := self startOfNextToken.
selector := self advance.
args := #().
words := OrderedCollection with: (start + requestorOffset to: self endOfLastToken + requestorOffset).
(Symbol hasInterned: selector ifTrue: [ :sym | selector := sym])
ifFalse: [ selector := self correctSelector: selector
wordIntervals: words
exprInterval: (start to: self endOfLastToken)
ifAbort: [ ^ self fail ] ].
precedence := 1]
ifFalse: [^args notNil]]].
parseNode := MessageNode new
receiver: receiver
selector: selector
arguments: args
precedence: precedence
from: encoder
sourceRange: (start to: self endOfLastToken).
repeat]
whileTrue: [].
^true!
Item was added:
+ ----- Method: Parser>>transformAVerticalBarIntoABinarySelector (in category 'scanning') -----
+ transformAVerticalBarIntoABinarySelector
+ "Transform a vertical bar into a binary selector.
+ Eventually aggregate a serie of immediately following vertical bars and a binary selector.
+ Note that this aggregation cannot occur at scan time, because a pair of vertical bars can be encountered in two valid constructs:
+ - either as an empty temporaries specification,
+ - or as a local temporaries specification in a block of arity > 0"
+ here := '|'.
+ hereType := #binary.
+ [tokenType == #verticalBar and: [hereMark + here size = mark]]
+ whileTrue: [
+ here := here , $|.
+ hereEnd := hereEnd + 1.
+ self scanToken].
+ (tokenType == #binary and: [hereMark + here size = mark])
+ ifTrue: [
+ here := here asString , token.
+ hereType := #binary.
+ hereEnd := hereEnd + token size.
+ self scanToken].!
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 or: [(self typeTableAt: hereChar) == #verticalBar]] whileTrue:
- [(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)].
token := token asSymbol!
More information about the Squeak-dev
mailing list
|