Scanner.st
changeset 996 53dbf13d1aa0
parent 983 bf808a409fd5
child 1001 1fcb7ffcdd3a
equal deleted inserted replaced
995:021cc3fb219b 996:53dbf13d1aa0
  1003 
  1003 
  1004     self initializeFor:aStringOrStream.
  1004     self initializeFor:aStringOrStream.
  1005     oldPos := source position.
  1005     oldPos := source position.
  1006     self nextToken.
  1006     self nextToken.
  1007     (tokenType == #Integer or:[tokenType == #Float]) ifTrue:[
  1007     (tokenType == #Integer or:[tokenType == #Float]) ifTrue:[
       
  1008         "/ must keep stream positioned correctly
       
  1009         "/ (undo lookahead)
       
  1010         peekChar notNil ifTrue:[
       
  1011             peekChar2 notNil ifTrue:[
       
  1012                 source skip:-1
       
  1013             ].
       
  1014             source skip:-1
       
  1015         ].
  1008         ^ tokenValue
  1016         ^ tokenValue
  1009     ].
  1017     ].
       
  1018     "/ backup in case of error; return nil
  1010     source position:oldPos.
  1019     source position:oldPos.
  1011     ^ nil.
  1020     ^ nil.
  1012 
  1021 
  1013     "Created: / 18.6.1998 / 23:05:22 / cg"
  1022     "Created: / 18.6.1998 / 23:05:22 / cg"
  1014     "Modified: / 18.6.1998 / 23:11:30 / cg"
  1023     "Modified: / 19.11.1999 / 18:25:52 / cg"
  1015 !
  1024 !
  1016 
  1025 
  1017 scanPositionsFor:aTokenString inString:aSourceString
  1026 scanPositionsFor:aTokenString inString:aSourceString
  1018     "scan aSourceString for occurrances of aTokenString.
  1027     "scan aSourceString for occurrances of aTokenString.
  1019      Return a collection of start positions.
  1028      Return a collection of start positions.
  2021 ! !
  2030 ! !
  2022 
  2031 
  2023 !Scanner class methodsFor:'documentation'!
  2032 !Scanner class methodsFor:'documentation'!
  2024 
  2033 
  2025 version
  2034 version
  2026     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.109 1999-10-06 13:58:56 cg Exp $'
  2035     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.110 1999-11-19 17:26:14 cg Exp $'
  2027 ! !
  2036 ! !
  2028 Scanner initialize!
  2037 Scanner initialize!