40
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
Object subclass:#MCScanner
|
|
4 |
instanceVariableNames:'stream'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
678
|
7 |
category:'SCM-Monticello-Chunk Format'
|
40
|
8 |
!
|
|
9 |
|
794
|
10 |
!MCScanner class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
I scan / tokenize metadata (package name, version info, ancestry, dependencies, ...) found in .mcz files.
|
|
15 |
|
|
16 |
For example, try:
|
|
17 |
|
|
18 |
MCScanner scan: '(name ''MyPackage-ll.6'' message ''Fix bug xxx'' id ''b21dbd73-f1c3-2746-a3cc-92f1d4edea28'')' readStream
|
|
19 |
"
|
|
20 |
! !
|
40
|
21 |
|
|
22 |
!MCScanner class methodsFor:'as yet unclassified'!
|
|
23 |
|
|
24 |
scan: aStream
|
939
|
25 |
^ (self new stream: aStream) next
|
|
26 |
|
|
27 |
"kludge:
|
225
|
28 |
|
|
29 |
| v |
|
|
30 |
[ v := (self new stream: aStream) next ]
|
|
31 |
on: RecursionInterruptSignal do:[:ex|ex proceed].
|
|
32 |
^v
|
|
33 |
"
|
|
34 |
|
|
35 |
"Modified: / 13-10-2010 / 15:52:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
40
|
36 |
!
|
|
37 |
|
|
38 |
scanTokens: aString
|
|
39 |
"compatibility"
|
|
40 |
^ Array with: (self scan: aString readStream)
|
|
41 |
! !
|
|
42 |
|
|
43 |
!MCScanner methodsFor:'as yet unclassified'!
|
|
44 |
|
|
45 |
next
|
225
|
46 |
|
|
47 |
| token stack array |
|
|
48 |
token := self nextToken.
|
|
49 |
token == $) ifTrue:[self error: 'Array not opened'].
|
|
50 |
token ~= $( ifTrue:[^token].
|
|
51 |
stack := Stack with: (array := OrderedCollection new).
|
|
52 |
[ stack isEmpty ] whileFalse:[
|
|
53 |
token := self nextToken.
|
|
54 |
token == $(
|
|
55 |
ifTrue:
|
|
56 |
[stack push: OrderedCollection new]
|
|
57 |
ifFalse:
|
|
58 |
[token == $)
|
|
59 |
ifTrue:
|
|
60 |
[|top|
|
|
61 |
top := stack top asArray.
|
|
62 |
stack pop.
|
|
63 |
stack size > 0 ifTrue:[stack top add: top]]
|
|
64 |
ifFalse:
|
|
65 |
[stack top add: token]]].
|
|
66 |
|
|
67 |
^array asArray
|
|
68 |
|
|
69 |
"Modified: / 28-10-2010 / 13:31:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
40
|
70 |
!
|
|
71 |
|
|
72 |
nextArray
|
|
73 |
stream next. "("
|
|
74 |
^ Array streamContents:
|
|
75 |
[:s |
|
|
76 |
[stream skipSeparators.
|
|
77 |
(stream peek = $)) or: [stream atEnd]] whileFalse: [s nextPut: self next].
|
|
78 |
stream next = $) ifFalse: [self error: 'Unclosed array']]
|
|
79 |
!
|
|
80 |
|
|
81 |
nextString
|
|
82 |
^ stream nextDelimited: $'
|
|
83 |
!
|
|
84 |
|
|
85 |
nextSymbol
|
|
86 |
^ (String streamContents:
|
|
87 |
[:s |
|
|
88 |
[stream peek isAlphaNumeric] whileTrue: [s nextPut: stream next]]) asSymbol
|
|
89 |
|
|
90 |
!
|
|
91 |
|
225
|
92 |
nextToken
|
|
93 |
| c |
|
|
94 |
stream skipSeparators.
|
|
95 |
c := stream peek.
|
|
96 |
c = $# ifTrue: [c := stream next; peek].
|
|
97 |
c = $' ifTrue: [^ self nextString].
|
|
98 |
c = $( ifTrue: [stream next.^ $(].
|
|
99 |
c = $) ifTrue: [stream next.^ $)].
|
|
100 |
c isAlphaNumeric ifTrue: [^ self nextSymbol].
|
|
101 |
self error: 'Unknown token type'.
|
|
102 |
|
|
103 |
"Created: / 28-10-2010 / 13:20:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
104 |
!
|
|
105 |
|
40
|
106 |
stream: aStream
|
225
|
107 |
stream := aStream
|
40
|
108 |
! !
|
|
109 |
|
|
110 |
!MCScanner class methodsFor:'documentation'!
|
|
111 |
|
|
112 |
version
|
939
|
113 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCScanner.st,v 1.6 2014-12-11 15:49:15 cg Exp $'
|
225
|
114 |
!
|
|
115 |
|
|
116 |
version_CVS
|
939
|
117 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCScanner.st,v 1.6 2014-12-11 15:49:15 cg Exp $'
|
225
|
118 |
!
|
|
119 |
|
|
120 |
version_SVN
|
939
|
121 |
^ '$Id: MCScanner.st,v 1.6 2014-12-11 15:49:15 cg Exp $'
|
40
|
122 |
! !
|
794
|
123 |
|