--- a/Scanner.st Thu Apr 07 15:32:16 2005 +0200
+++ b/Scanner.st Sat Apr 09 15:20:09 2005 +0200
@@ -636,12 +636,7 @@
!Scanner methodsFor:'accessing'!
comments
- "not yet implemented"
-
^ currentComments
-
- "Created: 20.4.1996 / 20:07:01 / cg"
- "Modified: 23.5.1997 / 12:14:45 / cg"
!
exitBlock:aBlock
@@ -1291,6 +1286,16 @@
!Scanner methodsFor:'general scanning'!
+scanDoing:aBlock
+ "scan, evaluating aBlock for every scanned token."
+
+ |t|
+
+ [(t := self nextToken) ~~ #EOF] whileTrue:[
+ aBlock value:t.
+ ].
+!
+
scanNumberFrom:aStringOrStream
"scan aSourceString for the next number in smalltalk syntax
Return the number or nil."
@@ -1322,18 +1327,20 @@
scanPositionsFor:aTokenString inString:aSourceString
"scan aSourceString for occurrances of aTokenString.
Return a collection of start positions.
- Added for VW compatibility (to support syntax-highlight)."
+ Added for VW compatibility (to support simple syntax-highlight)."
|searchType searchName searchValue positions t|
- "
- first, look what kind of token we have to search for
- "
- self initializeFor:(ReadStream on:aTokenString).
- self nextToken.
- searchType := tokenType.
- searchName := tokenName.
- searchValue := tokenValue.
+ aTokenString notNil ifTrue:[
+ "
+ first, look what kind of token we have to search for
+ "
+ self initializeFor:(ReadStream on:aTokenString).
+ self nextToken.
+ searchType := tokenType.
+ searchName := tokenName.
+ searchValue := tokenValue.
+ ].
"
start the real work ...
@@ -1342,13 +1349,13 @@
positions := OrderedCollection new.
[(t := self nextToken) ~~ #EOF] whileTrue:[
- searchType == t ifTrue:[
- (searchName isNil or:[tokenName = searchName]) ifTrue:[
- (searchValue isNil or:[tokenValue = searchValue]) ifTrue:[
- positions add:tokenPosition.
- ]
- ]
- ]
+ searchType == t ifTrue:[
+ (searchName isNil or:[tokenName = searchName]) ifTrue:[
+ (searchValue isNil or:[tokenValue = searchValue]) ifTrue:[
+ positions add:tokenPosition.
+ ]
+ ]
+ ]
].
^ positions
@@ -2764,7 +2771,7 @@
!Scanner class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.193 2005-03-22 09:04:41 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.194 2005-04-09 13:20:09 cg Exp $'
! !
Scanner initialize!