allow oldStyleAssignment setting added
authorClaus Gittinger <cg@exept.de>
Fri, 03 May 2002 14:15:22 +0200
changeset 1261 3de89ad9de69
parent 1260 50e4668049aa
child 1262 85c57c7eee77
allow oldStyleAssignment setting added
Scanner.st
--- a/Scanner.st	Fri May 03 14:15:12 2002 +0200
+++ b/Scanner.st	Fri May 03 14:15:22 2002 +0200
@@ -18,7 +18,7 @@
 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
 		saveComments currentComments collectedSource
 		allowUnderscoreInIdentifier allowDollarInIdentifier
-		scanColonAsKeyword warnSTXSpecialComment
+		allowOldStyleAssignment scanColonAsKeyword warnSTXSpecialComment
 		warnUnderscoreInIdentifier warnOldStyleAssignment
 		warnCommonMistakes outStream outCol warnSTXNameSpaceUse
 		warnPossibleIncompatibilities warnDollarInIdentifier
@@ -28,7 +28,8 @@
 		WarnCommonMistakes WarnPossibleIncompatibilities
 		WarnDollarInIdentifier AllowDollarInIdentifier
 		EmptySourceNotificationSignal AllowSqueakExtensions
-		AllowQualifiedNames AllowDolphinExtensions'
+		AllowQualifiedNames AllowDolphinExtensions
+		AllowOldStyleAssignment'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
@@ -239,6 +240,7 @@
 
     AllowUnderscoreInIdentifier := true.        "/ underscores in identifiers
     AllowDollarInIdentifier := false.           "/ st80-vms dollars in identifiers
+    AllowOldStyleAssignment := true.            "/ st80 underscore as assignment
     AllowSqueakExtensions := false.             "/ squeak computed array
     AllowQualifiedNames := false.               "/ vw3 qualified names
 
@@ -299,6 +301,19 @@
     "
 !
 
+allowOldStyleAssignment
+    "return true, if underscore-assignment (pre ST-80v4 syntax) are to be allowed"
+
+    ^ AllowOldStyleAssignment
+!
+
+allowOldStyleAssignment:aBoolean
+    "this allows turning on/off recognition of underscore-assignment (pre ST-80v4 syntax).
+     You must turn this off, if code with variables named '_' is to be filedIn"
+
+    AllowOldStyleAssignment := aBoolean
+!
+
 allowQualifiedNames
     "return true, if #{..} qualified names are allowed"
 
@@ -1186,6 +1201,7 @@
 
     allowUnderscoreInIdentifier := AllowUnderscoreInIdentifier.
     allowDollarInIdentifier := AllowDollarInIdentifier.
+    allowOldStyleAssignment := AllowOldStyleAssignment.
 
     "/ not used here, but eases subclassing for other languages.
     scanColonAsKeyword := true. 
@@ -1612,14 +1628,16 @@
         "/ could not arrive here if it was off
         "/
         nextChar := source nextPeek.
-        (nextChar isAlphaNumeric or:[nextChar == $_]) ifFalse:[
-            "oops: a single underscore is an old-style assignement"
-            nextChar ~~ $: ifTrue:[
-                self warnOldStyleAssignmentAt:tokenPosition.
-                source next.
-                tokenType := token := $_.
-                ^ tokenType
-            ]
+        allowOldStyleAssignment ifTrue:[
+            (nextChar isAlphaNumeric or:[nextChar == $_]) ifFalse:[
+                "oops: a single underscore is an old-style assignement"
+                nextChar ~~ $: ifTrue:[
+                    self warnOldStyleAssignmentAt:tokenPosition.
+                    source next.
+                    tokenType := token := $_.
+                    ^ tokenType
+                ]
+            ].
         ].
         string := '_'.
         self warnUnderscoreAt:tokenPosition.
@@ -2263,6 +2281,6 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.139 2002-02-08 14:45:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.140 2002-05-03 12:15:22 cg Exp $'
 ! !
 Scanner initialize!