--- a/Scanner.st Thu Mar 05 13:33:59 1998 +0100
+++ b/Scanner.st Thu Mar 05 13:47:30 1998 +0100
@@ -458,13 +458,13 @@
source next.
source skipSeparatorsExceptCR.
- hereChar := source peek.
+ hereChar := source peekOrNil.
hereChar isLetter ifTrue:[
directive := source nextWord.
- source peek == $: ifTrue:[
+ source peekOrNil == $: ifTrue:[
source next.
source skipSeparatorsExceptCR.
- hereChar := source peek.
+ hereChar := source peekOrNil.
"
Package: 'name-of-package'
@@ -533,10 +533,10 @@
].
]
].
- hereChar := source peek.
+ hereChar := source peekOrNil.
^ true.
- "Modified: 23.5.1997 / 12:15:24 / cg"
+ "Modified: / 5.3.1998 / 02:55:32 / cg"
!
parseDirectiveStringArg
@@ -570,16 +570,16 @@
[hereChar == $'] whileTrue:[
list addLast:self parseDirectiveStringArg.
source skipSeparatorsExceptCR.
- hereChar := source peek.
+ hereChar := source peekOrNil.
(hereChar == $,) ifTrue:[
source next.
source skipSeparatorsExceptCR.
- hereChar := source peek.
+ hereChar := source peekOrNil.
].
].
^ list
- "Modified: 23.5.1997 / 12:15:51 / cg"
+ "Modified: / 5.3.1998 / 02:55:40 / cg"
! !
!Scanner methodsFor:'error handling'!
@@ -1076,24 +1076,26 @@
index "{ Class: SmallInteger }"
max "{ Class: SmallInteger }" |
- nextChar := source peek.
+ nextChar := source peekOrNil.
string := String basicNew:20.
index := 0.
max := 10.
[true] whileTrue:[
- (nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[
- ^ string copyTo:index
- ].
- (index == max) ifTrue:[
- oldString := string.
- string := String basicNew:(max * 2).
- string replaceFrom:1 to:max with:oldString.
- max := max * 2
- ].
- index := index + 1.
- string at:index put:nextChar.
- nextChar := source nextPeek
+ (nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[
+ ^ string copyTo:index
+ ].
+ (index == max) ifTrue:[
+ oldString := string.
+ string := String basicNew:(max * 2).
+ string replaceFrom:1 to:max with:oldString.
+ max := max * 2
+ ].
+ index := index + 1.
+ string at:index put:nextChar.
+ nextChar := source nextPeek
]
+
+ "Modified: / 5.3.1998 / 02:53:57 / cg"
!
nextIdentifier
@@ -1126,13 +1128,13 @@
] ifFalse:[
string := source nextAlphaNumericWord "self nextId".
].
- nextChar := source peek.
+ nextChar := source peekOrNil.
(nextChar == $_
or:[nextChar == $$]) ifTrue:[
ok := (nextChar == $_) ifTrue:[AllowUnderscoreInIdentifier] ifFalse:[AllowDollarInIdentifier].
ok ifTrue:[
- pos := source position.
+ pos := source position.
nextChar == $_ ifTrue:[
self warnUnderscoreAt:pos.
] ifFalse:[
@@ -1143,7 +1145,7 @@
nextChar := source nextPeek.
(nextChar isAlphaNumeric) ifTrue:[
string := string , source nextAlphaNumericWord.
- nextChar := source peek.
+ nextChar := source peekOrNil.
].
(nextChar == $_) ifTrue:[
ok := AllowUnderscoreInIdentifier
@@ -1160,8 +1162,8 @@
(nextChar == $:) ifTrue:[
source next.
- (source peek == $=) ifFalse:[
- (source peek == $:) ifFalse:[
+ (source peekOrNil == $=) ifFalse:[
+ (source peekOrNil == $:) ifFalse:[
tokenName := token := string copyWith:nextChar.
tokenType := #Keyword.
^ self
@@ -1175,7 +1177,7 @@
].
nextChar == $- ifTrue:[
- pos := source position.
+ pos := source position.
self
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems'
position:pos to:pos.
@@ -1200,8 +1202,8 @@
tokenType := #Identifier.
^ tokenType
- "Created: 13.9.1995 / 12:56:42 / claus"
- "Modified: 7.9.1997 / 01:49:44 / cg"
+ "Created: / 13.9.1995 / 12:56:42 / claus"
+ "Modified: / 5.3.1998 / 02:53:43 / cg"
!
nextMantissa:radix
@@ -1209,13 +1211,15 @@
value := 0.
factor := 1.0 / radix.
- nextChar := source peek.
+ nextChar := source peekOrNil.
[(nextChar notNil and:[nextChar isDigitRadix:radix])] whileTrue:[
- value := value + (nextChar digitValue * factor).
- factor := factor / radix.
- nextChar := source nextPeek
+ value := value + (nextChar digitValue * factor).
+ factor := factor / radix.
+ nextChar := source nextPeek
].
^ value
+
+ "Modified: / 5.3.1998 / 02:54:11 / cg"
!
nextNumber
@@ -1223,24 +1227,24 @@
tokenRadix := 10.
value := Integer readFrom:source radix:tokenRadix.
- nextChar := source peek.
+ nextChar := source peekOrNil.
(nextChar == $r) ifTrue:[
tokenRadix := value.
source next.
s := 1.
- source peek == $- ifTrue:[
+ source peekOrNil == $- ifTrue:[
source next.
s := -1
].
value := Integer readFrom:source radix:tokenRadix.
value := value * s.
- nextChar := source peek
+ nextChar := source peekOrNil
].
(nextChar == $.) ifTrue:[
nextChar := source nextPeek.
(nextChar notNil and:[nextChar isDigitRadix:tokenRadix]) ifTrue:[
value := value asFloat + (self nextMantissa:tokenRadix).
- nextChar := source peek
+ nextChar := source peekOrNil
] ifFalse:[
"/ nextChar == (Character cr) ifTrue:[
"/ lineNr := lineNr + 1.
@@ -1281,7 +1285,7 @@
].
^ tokenType
- "Modified: 20.6.1997 / 17:53:55 / cg"
+ "Modified: / 5.3.1998 / 02:54:36 / cg"
!
nextPrimitive
@@ -1311,7 +1315,7 @@
index := index + 1.
nextChar := source next
].
- (source peek == $}) ifTrue:[
+ (source peekOrNil == $}) ifTrue:[
inPrimitive := false
] ifFalse:[
string at:index put:nextChar.
@@ -1340,7 +1344,7 @@
^ #Error
"
- "Modified: 20.6.1997 / 17:54:08 / cg"
+ "Modified: / 5.3.1998 / 02:54:43 / cg"
!
nextSpecial
@@ -1350,7 +1354,7 @@
|firstChar secondChar thirdChar string p|
firstChar := source next.
- secondChar := source peek.
+ secondChar := source peekOrNil.
((firstChar == $-) and:[secondChar notNil]) ifTrue:[
secondChar isDigit ifTrue:[
self nextNumber.
@@ -1365,7 +1369,7 @@
"special- look if minus belongs to number following"
p := source position.
source next.
- thirdChar := source peek.
+ thirdChar := source peekOrNil.
source position:p.
thirdChar isDigit ifTrue:[
tokenName := token := string.
@@ -1385,7 +1389,7 @@
tokenType := #BinaryOperator.
^ tokenType
- "Modified: 20.6.1997 / 17:54:22 / cg"
+ "Modified: / 5.3.1998 / 02:54:54 / cg"
!
nextString
@@ -1414,7 +1418,7 @@
lineNr := lineNr + 1
].
(nextChar == Character quote) ifTrue:[
- (source peek == Character quote) ifTrue:[
+ (source peekOrNil == Character quote) ifTrue:[
source next
] ifFalse:[
inString := false
@@ -1434,7 +1438,7 @@
tokenType := #String.
^ tokenType
- "Modified: 20.6.1997 / 17:54:38 / cg"
+ "Modified: / 5.3.1998 / 02:55:01 / cg"
!
nextToken
@@ -1462,7 +1466,7 @@
[skipping] whileTrue:[
outStream notNil ifTrue:[
- hereChar := source peek.
+ hereChar := source peekOrNil.
[(hereChar == Character space)
or:[hereChar isSeparator]
] whileTrue:[
@@ -1493,7 +1497,7 @@
"start of a comment"
self skipComment.
- hereChar := source peek.
+ hereChar := source peekOrNil.
] ifFalse:[
skipping := false
]
@@ -1524,8 +1528,8 @@
tokenType := #Error.
^ #Error
- "Modified: 13.9.1995 / 12:56:14 / claus"
- "Modified: 30.8.1997 / 00:56:08 / cg"
+ "Modified: / 13.9.1995 / 12:56:14 / claus"
+ "Modified: / 5.3.1998 / 02:55:17 / cg"
!
nextToken:aCharacter
@@ -1551,7 +1555,7 @@
startPos := source position.
source next.
- hereChar := source peek.
+ hereChar := source peekOrNil.
"
special ST/X addition:
@@ -1631,7 +1635,7 @@
self endComment:(commentStream contents) type:commentType.
].
- "Modified: / 17.2.1998 / 18:35:33 / cg"
+ "Modified: / 5.3.1998 / 02:55:48 / cg"
! !
!Scanner::Comment methodsFor:'accessing'!
@@ -1677,6 +1681,6 @@
!Scanner class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.74 1998-02-27 12:54:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.75 1998-03-05 12:47:30 cg Exp $'
! !
Scanner initialize!