made scanner tables instVars - for easier subclassability
authorClaus Gittinger <cg@exept.de>
Wed, 13 May 1998 15:50:13 +0200
changeset 708 11837544357d
parent 707 2fe4b3a7708a
child 709 b4351947a598
made scanner tables instVars - for easier subclassability
Scanner.st
--- a/Scanner.st	Wed May 13 15:12:28 1998 +0200
+++ b/Scanner.st	Wed May 13 15:50:13 1998 +0200
@@ -11,10 +11,12 @@
 "
 
 Object subclass:#Scanner
-	instanceVariableNames:'source lineNr collectedSource token tokenType tokenPosition
+	instanceVariableNames:'typeArray actionArray source lineNr
+	        token tokenType tokenPosition
 		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
-		saveComments currentComments warnSTXSpecialComment
+		saveComments currentComments collectedSource
+		allowUnderscoreInIdentifier allowDollarInIdentifier warnSTXSpecialComment
 		warnUnderscoreInIdentifier warnOldStyleAssignment
 		warnCommonMistakes outStream outCol warnSTXNameSpaceUse
 		warnPossibleIncompatibilities warnDollarInIdentifier'
@@ -846,6 +848,7 @@
     saveComments := false.
     ignoreErrors := false.
     ignoreWarnings := Warnings not.
+
     warnSTXSpecialComment := WarnSTXSpecials.
     warnSTXNameSpaceUse := WarnSTXSpecials.
     warnUnderscoreInIdentifier := WarnUnderscoreInIdentifier.
@@ -853,9 +856,15 @@
     warnOldStyleAssignment := WarnOldStyleAssignment.
     warnCommonMistakes := WarnCommonMistakes.
     warnPossibleIncompatibilities := WarnPossibleIncompatibilities.
+
+    allowUnderscoreInIdentifier := AllowUnderscoreInIdentifier.
+    allowDollarInIdentifier := AllowDollarInIdentifier.
+
     ActionArray isNil ifTrue:[
         self class setupActions
-    ]
+    ].
+    actionArray := ActionArray.
+    typeArray := TypeArray.
 
     "Modified: 7.9.1997 / 01:51:01 / cg"
 !
@@ -1035,11 +1044,11 @@
     nextChar := source nextPeek.
     nextChar notNil ifTrue:[
         (nextChar isLetterOrDigit
-        or:[(AllowUnderscoreInIdentifier == true) and:[nextChar == $_]]) ifTrue:[
+        or:[(allowUnderscoreInIdentifier == true) and:[nextChar == $_]]) ifTrue:[
             string := ''.
             [nextChar notNil 
              and:[nextChar isLetterOrDigit 
-                  or:[AllowUnderscoreInIdentifier == true
+                  or:[allowUnderscoreInIdentifier == true
                       and:[nextChar == $_]]
                  ]
             ] whileTrue:[
@@ -1048,7 +1057,7 @@
                     string := string , part.
                 ].
                 nextChar := source peek.
-                AllowUnderscoreInIdentifier == true ifTrue:[
+                allowUnderscoreInIdentifier == true ifTrue:[
                     nextChar == $_ ifTrue:[
                         self warnUnderscoreAt:source position.
                     ].
@@ -1097,11 +1106,11 @@
             tokenType := #Symbol.
             ^ tokenType
         ].
-        ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
+        ((typeArray at:(nextChar asciiValue)) == #special) ifTrue:[
             string := source next asString.
             nextChar := source peek.
             nextChar notNil ifTrue:[
-                ((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[
+                ((typeArray at:(nextChar asciiValue)) == #special) ifTrue:[
                     source next.
                     string := string copyWith:nextChar
                 ]
@@ -1160,7 +1169,7 @@
 
     hereChar == $_ ifTrue:[
         "/
-        "/ no need to check for AllowUnderscoreInIdentifier here;
+        "/ no need to check for allowUnderscoreInIdentifier here;
         "/ could not arrive here if it was off
         "/
         nextChar := source nextPeek.
@@ -1189,7 +1198,7 @@
 
     (nextChar == $_ 
     or:[nextChar == $$]) ifTrue:[
-        ok := (nextChar == $_) ifTrue:[AllowUnderscoreInIdentifier] ifFalse:[AllowDollarInIdentifier].
+        ok := (nextChar == $_) ifTrue:[allowUnderscoreInIdentifier] ifFalse:[allowDollarInIdentifier].
         ok ifTrue:[
             pos := source position.
             nextChar == $_ ifTrue:[
@@ -1205,10 +1214,10 @@
                     nextChar := source peekOrNil.
                 ].
                 (nextChar == $_) ifTrue:[
-                    ok := AllowUnderscoreInIdentifier
+                    ok := allowUnderscoreInIdentifier
                 ] ifFalse:[
                     (nextChar == $$) ifTrue:[
-                        ok := AllowDollarInIdentifier
+                        ok := allowDollarInIdentifier
                     ] ifFalse:[
                         ok := false
                     ]
@@ -1409,7 +1418,7 @@
     ].
     string := firstChar asString.
     secondChar notNil ifTrue:[
-        ((TypeArray at:(secondChar asciiValue)) == #special) ifTrue:[
+        ((typeArray at:(secondChar asciiValue)) == #special) ifTrue:[
             (secondChar == $-) ifTrue:[
                 "special- look if minus belongs to number following"
                 p := source position.
@@ -1565,7 +1574,7 @@
     (v := ch asciiValue) == 0 ifTrue:[
         v := Character space asciiValue
     ].
-    actionBlock := ActionArray at:v.
+    actionBlock := actionArray at:v.
     actionBlock notNil ifTrue:[
         ^ actionBlock value:self value:ch
     ].
@@ -1735,6 +1744,6 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.80 1998-05-13 13:12:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.81 1998-05-13 13:50:13 cg Exp $'
 ! !
 Scanner initialize!