scanning of keyword symbols in array consts fixed
authorClaus Gittinger <cg@exept.de>
Wed, 17 Oct 2001 15:09:13 +0200
changeset 1202 95abdd4272cd
parent 1201 d38dbc8f2961
child 1203 2bd6633eced0
scanning of keyword symbols in array consts fixed
Parser.st
Scanner.st
--- a/Parser.st	Wed Oct 10 18:48:41 2001 +0200
+++ b/Parser.st	Wed Oct 17 15:09:13 2001 +0200
@@ -4822,12 +4822,15 @@
     ].
 
     (tokenType == #HashLeftParen) ifTrue:[
+        self inArrayLiteral:true.
         self nextToken.
         ParseErrorSignal handle:[:ex |
+            self inArrayLiteral:false.
             ^ #Error
         ] do:[
             val := self array.
         ].
+        self inArrayLiteral:false.
         self nextToken.
         (self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[
             ^ #Error
@@ -5987,6 +5990,6 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.305 2001-10-09 07:41:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.306 2001-10-17 13:09:06 cg Exp $'
 ! !
 Parser initialize!
--- a/Scanner.st	Wed Oct 10 18:48:41 2001 +0200
+++ b/Scanner.st	Wed Oct 17 15:09:13 2001 +0200
@@ -21,7 +21,8 @@
 		scanColonAsKeyword warnSTXSpecialComment
 		warnUnderscoreInIdentifier warnOldStyleAssignment
 		warnCommonMistakes outStream outCol warnSTXNameSpaceUse
-		warnPossibleIncompatibilities warnDollarInIdentifier'
+		warnPossibleIncompatibilities warnDollarInIdentifier
+		inArrayLiteral'
 	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
 		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
 		WarnCommonMistakes WarnPossibleIncompatibilities
@@ -586,6 +587,10 @@
     "Modified: 23.5.1997 / 12:14:45 / cg"
 !
 
+inArrayLiteral:aBoolean
+    inArrayLiteral := aBoolean
+!
+
 lineNumber
     ^ lineNr
 !
@@ -1557,6 +1562,19 @@
             (ch2 == $:) ifFalse:[
                 tokenName := token := string copyWith:nextChar.
                 tokenType := #Keyword.
+                inArrayLiteral == true ifTrue:[
+                    (ch2 isLetter 
+                    or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]) ifTrue:[
+                        "/ kludge: recurse to read the rest.
+                        self nextIdentifier.
+                        tokenName := token := (string copyWith:nextChar) , token.   
+                        tokenType ~~ #Keyword ifTrue:[
+                            self syntaxError:'invalid keyword symbol in array constant'
+                                    position:tokenPosition to:(source position - 1).
+                        ].
+                        tokenType := #Keyword.
+                    ].
+                ].
                 ^ tokenType
             ].
             peekChar := $:.
@@ -2130,6 +2148,6 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.128 2001-10-02 11:38:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.129 2001-10-17 13:09:13 cg Exp $'
 ! !
 Scanner initialize!