--- a/Parser.st Tue Apr 01 16:22:50 2003 +0200
+++ b/Parser.st Wed Apr 02 12:15:48 2003 +0200
@@ -2516,7 +2516,9 @@
startSearch := defStartPos+1.
[
- "/ search this names position in the declaration part ...
+ |prevChar isFirstVar|
+
+ "/ search this name's position in the declaration part ...
pos := source indexOfSubCollection:varName startingAt:startSearch ifAbsent:0.
(pos == 0 or:[pos >= defEndPos]) ifTrue:[
self error:'should not happen' mayProceed:true.
@@ -2524,19 +2526,46 @@
].
pos2 := pos + varName size - 1.
- nextChar := source at:pos2+1.
- nextChar isLetterOrDigit ifFalse:[
- (source at:pos-1) == Character space ifTrue:[
- pos := pos - 1.
+ pos > 1 ifTrue:[
+ prevChar := source at:pos-1.
+ ].
+ (prevChar isNil or:[prevChar isLetterOrDigit not]) ifTrue:[
+ nextChar := source at:pos2+1.
+ nextChar isLetterOrDigit ifFalse:[
+ "/ halfway intuitive space-removal behavior;
+ "/ if there was a space after/before the |-char,
+ "/ leave it; otherwise remove it.
+ isFirstVar := pos == (defStartPos+1).
+ (source at:pos-1) == Character space ifTrue:[
+ pos := pos - 1.
+ [ (source at:pos-1) == Character space] whileTrue:[
+ pos := pos - 1.
+ ].
+ (source at:pos-1) == $| ifTrue:[
+ "/ there was a space before - leave it
+ pos := pos + 1.
+ isFirstVar := true.
+ ]
+ ].
+
+ (source at:pos2+1) == Character space ifTrue:[
+ pos2 := pos2 + 1.
+ [ (source at:pos2+1) == Character space] whileTrue:[
+ pos2 := pos2 + 1.
+ ].
+ (source at:pos2+1) == $| ifTrue:[
+ "/ there was a space after - leave it
+ pos2 := pos2 - 1.
+ ] ifFalse:[
+ isFirstVar ifFalse:[
+ pos2 := pos2 - 1.
+ ]
+ ].
+ ].
+
+ self correctSourceByDeletingFrom:pos to:pos2.
+ ^ self.
].
-
-"/ [nextChar == Character space] whileTrue:[
-"/ pos2 := pos2 + 1.
-"/ nextChar := source at:pos2+1.
-"/ ].
-"/
- self correctSourceByDeletingFrom:pos to:pos2.
- ^ self.
].
startSearch := pos2 + 1.
] loop
@@ -7063,7 +7092,7 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.375 2003-04-01 14:22:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.376 2003-04-02 10:15:48 cg Exp $'
! !
Parser initialize!