Scanner.st
changeset 505 793f88ee6269
parent 500 d0679fcc520e
child 526 adb8aed3a691
--- a/Scanner.st	Fri Apr 11 15:51:19 1997 +0200
+++ b/Scanner.st	Fri Apr 11 16:45:46 1997 +0200
@@ -996,35 +996,40 @@
     len := 500.
     index := 1.
     (nextChar == ${) ifTrue:[
-	nextChar := source nextPeek.
-	inPrimitive := true.
-	[inPrimitive] whileTrue:[
-	    [nextChar == $%] whileFalse:[
-		string at:index put:nextChar.
-		(index == len) ifTrue:[
-		    string := string , (String new:len).
-		    len := len * 2
-		].
-		index := index + 1.
-		nextChar := source next
-	    ].
-	    (source peek == $}) ifTrue:[
-		inPrimitive := false
-	    ] ifFalse:[
-		string at:index put:nextChar.
-		(index == len) ifTrue:[
-		    string := string , (String new:len).
-		    len := len * 2
-		].
-		index := index + 1.
-		nextChar := source next
-	    ]
-	].
-	source next.
-	tokenValue := string copyTo:(index - 1).
-	tokenType := #Primitive.
-	tokenLineNr := tokenLineNr + (tokenValue occurrencesOf:(Character cr)).
-	^ tokenType
+        nextChar := source nextPeek.
+        inPrimitive := true.
+        [inPrimitive] whileTrue:[
+            [nextChar == $%] whileFalse:[
+                nextChar isNil ifTrue:[
+                    self syntaxError:'unterminated primitive'
+                            position:tokenPosition to:source position.
+                    ^ #Error
+                ].
+                string at:index put:nextChar.
+                (index == len) ifTrue:[
+                    string := string , (String new:len).
+                    len := len * 2
+                ].
+                index := index + 1.
+                nextChar := source next
+            ].
+            (source peek == $}) ifTrue:[
+                inPrimitive := false
+            ] ifFalse:[
+                string at:index put:nextChar.
+                (index == len) ifTrue:[
+                    string := string , (String new:len).
+                    len := len * 2
+                ].
+                index := index + 1.
+                nextChar := source next
+            ]
+        ].
+        source next.
+        tokenValue := string copyTo:(index - 1).
+        tokenType := #Primitive.
+        tokenLineNr := tokenLineNr + (tokenValue occurrencesOf:(Character cr)).
+        ^ tokenType
     ].
 
     "a % alone is a binary operator"
@@ -1033,9 +1038,11 @@
     ^ tokenType.
 "
     self syntaxError:('invalid character: ''' , nextChar asString , '''')
-	    position:tokenPosition to:(tokenPosition + 1).
+            position:tokenPosition to:(tokenPosition + 1).
     ^ #Error
 "
+
+    "Modified: 11.4.1997 / 16:11:08 / cg"
 !
 
 nextSpecial
@@ -1304,6 +1311,6 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.64 1997-04-05 17:02:51 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.65 1997-04-11 14:45:46 cg Exp $'
 ! !
 Scanner initialize!