added: #version_CVS
authorClaus Gittinger <cg@exept.de>
Sat, 20 Aug 2011 13:44:54 +0200
changeset 225 4453a8f6fb4a
parent 224 6e44151e334c
child 226 65c367458c4f
added: #version_CVS
MCScanner.st
--- a/MCScanner.st	Sat Aug 20 13:44:49 2011 +0200
+++ b/MCScanner.st	Sat Aug 20 13:44:54 2011 +0200
@@ -11,7 +11,17 @@
 !MCScanner class methodsFor:'as yet unclassified'!
 
 scan: aStream
-	^ (self new stream: aStream) next
+
+    | v |
+    "Kludge"
+    ^ (self new stream: aStream) next
+    "
+    [ v := (self new stream: aStream) next ]
+        on: RecursionInterruptSignal do:[:ex|ex proceed].
+    ^v
+    "
+
+    "Modified: / 13-10-2010 / 15:52:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 scanTokens: aString
@@ -22,14 +32,30 @@
 !MCScanner methodsFor:'as yet unclassified'!
 
 next
-	| c |
-	stream skipSeparators.
-	c _ stream peek.
-	c = $# ifTrue: [c _ stream next; peek].
-	c = $' ifTrue: [^ self nextString].
-	c = $( ifTrue: [^ self nextArray].
-	c isAlphaNumeric ifTrue: [^ self nextSymbol].
-	self error: 'Unknown token type'.	
+
+    | token stack array |
+    token := self nextToken.
+    token == $) ifTrue:[self error: 'Array not opened'].
+    token ~= $( ifTrue:[^token].
+    stack := Stack with: (array := OrderedCollection new).
+    [ stack isEmpty ] whileFalse:[
+        token := self nextToken.
+        token == $( 
+            ifTrue:
+                [stack push: OrderedCollection new]
+            ifFalse:
+                [token == $) 
+                    ifTrue:
+                        [|top|
+                        top := stack top asArray.
+                        stack pop.
+                        stack size > 0 ifTrue:[stack top add: top]]
+                    ifFalse:
+                        [stack top add: token]]].
+
+    ^array asArray
+
+    "Modified: / 28-10-2010 / 13:31:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 nextArray
@@ -52,12 +78,34 @@
 			
 !
 
+nextToken
+        | c |
+        stream skipSeparators.
+        c := stream peek.
+        c = $# ifTrue: [c := stream next; peek].
+        c = $' ifTrue: [^ self nextString].
+        c = $( ifTrue: [stream next.^ $(].
+        c = $) ifTrue: [stream next.^ $)].
+        c isAlphaNumeric ifTrue: [^ self nextSymbol].
+        self error: 'Unknown token type'.
+
+    "Created: / 28-10-2010 / 13:20:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 stream: aStream
-	stream _ aStream
+	stream := aStream
 ! !
 
 !MCScanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCScanner.st,v 1.1 2006-11-22 13:06:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCScanner.st,v 1.2 2011-08-20 11:44:54 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCScanner.st,v 1.2 2011-08-20 11:44:54 cg Exp $'
+!
+
+version_SVN
+    ^ '§Id: MCScanner.st 23 2010-10-29 14:41:24Z vranyj1 §'
 ! !