type- and actionArray are now class-instance variables
authorClaus Gittinger <cg@exept.de>
Tue, 16 Dec 2008 15:31:01 +0100
changeset 2140 f9b4ef3e9368
parent 2139 ff81d8aadd3f
child 2141 de005dc56384
type- and actionArray are now class-instance variables
Scanner.st
--- a/Scanner.st	Tue Dec 16 13:42:27 2008 +0100
+++ b/Scanner.st	Tue Dec 16 15:31:01 2008 +0100
@@ -19,11 +19,19 @@
 		outStream outCol inArrayLiteral lastDirective parserFlags
 		didWarnAboutSTXSpecialComment didWarnAboutUnderscoreInIdentifier
 		didWarnAboutOldStyleAssignment didWarnAboutDollarInIdentifier'
-	classVariableNames:'TypeArray ActionArray Warnings EmptySourceNotificationSignal'
+	classVariableNames:'DefaultTypeArray DefaultActionArray Warnings
+		EmptySourceNotificationSignal'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
 
+Scanner class instanceVariableNames:'TypeArray ActionArray'
+
+"
+ No other class instance variables are inherited by this class.
+"
+!
+
 Object subclass:#Comment
 	instanceVariableNames:'commentType commentString'
 	classVariableNames:''
@@ -152,59 +160,62 @@
     "initialize the scanners actionTables - these are used to dispatch
      into scanner methods as characters are read"
 
-    |block|
-
-    ActionArray := Array new:256.
-    TypeArray := Array new:256.
+    |block actionArray typeArray|
+
+    actionArray := Array new:256.
+    typeArray := Array new:256.
 
     "/ TODO: later versions should be configurable w.r.t separators.
     "/ #(9 10 12 13 26 32) do: [:i | TypeArray at:(i+1) put: #separator].
 
     block := [:s :char | s nextNumber].
     ($0 codePoint) to:($9 codePoint) do:[:index |
-        ActionArray at:index put:block
+        actionArray at:index put:block
     ].
 
     block := [:s :char | s nextSpecial].
     self binarySelectorCharacters do:[:binop |
-        TypeArray at:(binop codePoint) put:#special.
-        ActionArray at:(binop codePoint) put:block
+        typeArray at:(binop codePoint) put:#special.
+        actionArray at:(binop codePoint) put:block
     ].
     block := [:s :char | s nextExtendedSpecial].
     self extendedBinarySelectorCharacters do:[:binop |
-        TypeArray at:(binop codePoint) put:#extendedSpecial.
-        ActionArray at:(binop codePoint) put:block
+        typeArray at:(binop codePoint) put:#extendedSpecial.
+        actionArray at:(binop codePoint) put:block
     ].
 
     "/ that one is a special case (both binarySelector AND syntax).
-    TypeArray at:($| codePoint) put:nil.
+    typeArray at:($| codePoint) put:nil.
 
     block := [:s :char | s nextToken:char].
     ';.^|()[]{}' do:[:ch |
-        ActionArray at:(ch codePoint) put:block
+        actionArray at:(ch codePoint) put:block
     ].
 
     block := [:s :char | s nextIdentifier].
     ($a codePoint) to:($z codePoint) do:[:index |
-        ActionArray at:index put:block
+        actionArray at:index put:block
     ].
     ($A codePoint) to:($Z codePoint) do:[:index |
-        ActionArray at:index put:block
+        actionArray at:index put:block
     ].
 
     "kludge: action is characterToken, but type is special"
-    TypeArray at:($| codePoint) put:#special.
+    typeArray at:($| codePoint) put:#special.
 
     "kludge: action is nextColonOrAssign, but type is special"
-    TypeArray at:($: codePoint) put:#special.
-
-    ActionArray at:($' codePoint) put:[:s :char | s nextString:char].
-    ActionArray at:($$ codePoint) put:[:s :char | s nextCharacter].
-    ActionArray at:($# codePoint) put:[:s :char | s nextHash].
-    ActionArray at:($!! codePoint) put:[:s :char | s nextExcla].
-    ActionArray at:($% codePoint) put:[:s :char | s nextPrimitive].
-    ActionArray at:($: codePoint) put:[:s :char | s nextColonOrAssign].
-    ActionArray at:($_ codePoint) put:[:s :char | s nextUnderline].
+    typeArray at:($: codePoint) put:#special.
+
+    actionArray at:($' codePoint) put:[:s :char | s nextString:char].
+    actionArray at:($$ codePoint) put:[:s :char | s nextCharacter].
+    actionArray at:($# codePoint) put:[:s :char | s nextHash].
+    actionArray at:($!! codePoint) put:[:s :char | s nextExcla].
+    actionArray at:($% codePoint) put:[:s :char | s nextPrimitive].
+    actionArray at:($: codePoint) put:[:s :char | s nextColonOrAssign].
+    actionArray at:($_ codePoint) put:[:s :char | s nextUnderline].
+
+    ActionArray := DefaultActionArray := actionArray.
+    TypeArray := DefaultTypeArray := typeArray.
 
     "
      Scanner setupActions
@@ -244,6 +255,22 @@
     "Created: / 16.5.1998 / 15:55:14 / cg"
 ! !
 
+!Scanner class methodsFor:'accessing'!
+
+actionArray
+    ActionArray isNil ifTrue:[
+        self setupActions
+    ].
+    ^ ActionArray ? DefaultActionArray
+!
+
+typeArray
+    TypeArray isNil ifTrue:[
+        self setupActions
+    ].
+    ^ TypeArray ? DefaultTypeArray
+! !
+
 !Scanner class methodsFor:'class initialization'!
 
 initialize
@@ -1702,11 +1729,8 @@
 !
 
 initializeActionTable
-    ActionArray isNil ifTrue:[
-        self class setupActions
-    ].
-    actionArray := ActionArray.
-    typeArray := TypeArray.
+    actionArray := self class actionArray.
+    typeArray := self class typeArray.
 
     "Created: / 18-10-2006 / 23:10:55 / cg"
 !
@@ -3182,7 +3206,7 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.241 2008-12-16 12:42:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.242 2008-12-16 14:31:01 cg Exp $'
 ! !
 
 Scanner initialize!