Scanner.st
changeset 7 6c2bc76f0b8f
parent 4 f6fd83437415
child 10 73e97b6175c4
--- a/Scanner.st	Sat Dec 11 02:07:55 1993 +0100
+++ b/Scanner.st	Sat Dec 11 02:09:49 1993 +0100
@@ -16,8 +16,8 @@
                               tokenName tokenLineNr
                               thisChar peekChar
                               requestor exitBlock
-                              errorFlag
-			      saveComments currentComments'
+                              errorFlag ignoreErrors
+                              saveComments currentComments'
           classVariableNames:'typeArray actionArray'
             poolDictionaries:''
                     category:'System-Compiler'
@@ -29,7 +29,7 @@
              All Rights Reserved
 
 Scanner reads from a stream and returns individual smalltalk tokens
-$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.3 1993-10-13 02:41:45 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.4 1993-12-11 01:09:49 claus Exp $
 '!
 
 !Scanner class methodsFor:'instance creation'!
@@ -53,6 +53,7 @@
     source := aStream.
     currentComments := nil.
     saveComments := false.
+    ignoreErrors := false.
 
     actionArray isNil ifTrue:[
         actionArray := Array new:256.
@@ -100,6 +101,7 @@
     tokenLineNr := 1.
     currentComments := nil.
     saveComments := false.
+    ignoreErrors := false.
 !
 
 notifying:anObject
@@ -108,6 +110,12 @@
     requestor := anObject
 !
 
+ignoreErrors
+    "turn off notification of errors"
+
+    ignoreErrors := true
+!
+
 backupPosition
     "if reading from a stream, at the end we might have read
      one token too many"
@@ -122,7 +130,9 @@
 showErrorMessage:aMessage position:pos
     "show an errormessage on the Transcript"
 
-    Transcript showCr:(pos printString , ' ' , aMessage)
+    ignoreErrors ifFalse:[
+        Transcript showCr:(pos printString , ' ' , aMessage)
+    ]
 !
 
 notifyError:aMessage position:position to:endPos
@@ -134,6 +144,7 @@
         self showErrorMessage:aMessage position:position.
         ^ false
     ].
+
     ^ requestor error:aMessage position:position to:endPos
 !
 
@@ -190,29 +201,34 @@
 !Scanner methodsFor:'reading next token'!
 
 skipComment
-    |comment|
+    |comment startPos|
 
     comment := ''.
 
+    startPos := source position.
     source next.
     thisChar := source peek.
     [thisChar notNil and:[thisChar ~~ (Character doubleQuote)]] whileTrue:[
         thisChar == (Character cr) ifTrue:[
             tokenLineNr := tokenLineNr + 1.
         ].
-	saveComments ifTrue:[
-	    comment := comment copyWith:thisChar
-	].
+        saveComments ifTrue:[
+            comment := comment copyWith:thisChar
+        ].
         source next.
         thisChar := source peek
     ].
     saveComments ifTrue:[
         currentComments isNil ifTrue:[
-	    currentComments := OrderedCollection with:comment
+            currentComments := OrderedCollection with:comment
         ] ifFalse:[
-	    currentComments add:comment
+            currentComments add:comment
         ]
     ].
+
+    thisChar isNil ifTrue:[
+        self warning:'unclosed comment' position:startPos to:(source position)
+    ].
     "skip final dQuote"
     source next.
 !
@@ -234,9 +250,9 @@
                 source next
             ] ifFalse:[
                 thisChar == (Character doubleQuote) ifTrue:[
-		    "start of a comment"
+                    "start of a comment"
 
-		    self skipComment.
+                    self skipComment.
                     thisChar := source peek.
                 ] ifFalse:[
                     skipping := false
@@ -519,7 +535,7 @@
                 nextChar := source peek.
                 (nextChar == $:) ifFalse:[
                     tokenValue := string asSymbol.
-            	    tokenType := #Symbol.
+                    tokenType := #Symbol.
                     ^ tokenType
                 ].
                 string := string copyWith:nextChar.