40
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
Object subclass:#MCScanner
|
|
4 |
instanceVariableNames:'stream'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Chunk Format'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCScanner class methodsFor:'as yet unclassified'!
|
|
12 |
|
|
13 |
scan: aStream
|
|
14 |
^ (self new stream: aStream) next
|
|
15 |
!
|
|
16 |
|
|
17 |
scanTokens: aString
|
|
18 |
"compatibility"
|
|
19 |
^ Array with: (self scan: aString readStream)
|
|
20 |
! !
|
|
21 |
|
|
22 |
!MCScanner methodsFor:'as yet unclassified'!
|
|
23 |
|
|
24 |
next
|
|
25 |
| c |
|
|
26 |
stream skipSeparators.
|
|
27 |
c _ stream peek.
|
|
28 |
c = $# ifTrue: [c _ stream next; peek].
|
|
29 |
c = $' ifTrue: [^ self nextString].
|
|
30 |
c = $( ifTrue: [^ self nextArray].
|
|
31 |
c isAlphaNumeric ifTrue: [^ self nextSymbol].
|
|
32 |
self error: 'Unknown token type'.
|
|
33 |
!
|
|
34 |
|
|
35 |
nextArray
|
|
36 |
stream next. "("
|
|
37 |
^ Array streamContents:
|
|
38 |
[:s |
|
|
39 |
[stream skipSeparators.
|
|
40 |
(stream peek = $)) or: [stream atEnd]] whileFalse: [s nextPut: self next].
|
|
41 |
stream next = $) ifFalse: [self error: 'Unclosed array']]
|
|
42 |
!
|
|
43 |
|
|
44 |
nextString
|
|
45 |
^ stream nextDelimited: $'
|
|
46 |
!
|
|
47 |
|
|
48 |
nextSymbol
|
|
49 |
^ (String streamContents:
|
|
50 |
[:s |
|
|
51 |
[stream peek isAlphaNumeric] whileTrue: [s nextPut: stream next]]) asSymbol
|
|
52 |
|
|
53 |
!
|
|
54 |
|
|
55 |
stream: aStream
|
|
56 |
stream _ aStream
|
|
57 |
! !
|
|
58 |
|
|
59 |
!MCScanner class methodsFor:'documentation'!
|
|
60 |
|
|
61 |
version
|
|
62 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCScanner.st,v 1.1 2006-11-22 13:06:28 cg Exp $'
|
|
63 |
! !
|