V'Age ESSymbols
authorClaus Gittinger <cg@exept.de>
Fri, 03 Feb 2006 17:16:49 +0100
changeset 1656 04303a87cae4
parent 1655 e38e77f7d6d0
child 1657 451328cc3264
V'Age ESSymbols
Scanner.st
--- a/Scanner.st	Fri Feb 03 17:06:37 2006 +0100
+++ b/Scanner.st	Fri Feb 03 17:16:49 2006 +0100
@@ -2000,64 +2000,12 @@
         HashHash          (for '##' )
     "
 
-    |nextChar string part isNameSpaceSymbol allowUnderscoreInIdentifier|
+    |nextChar string allowUnderscoreInIdentifier|
 
     allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier.
 
     nextChar := source nextPeek.
     nextChar notNil ifTrue:[
-        isNameSpaceSymbol := false.
-        (nextChar isLetter
-        or:[(nextChar == $_) and:[allowUnderscoreInIdentifier]]) ifTrue:[
-            string := ''.
-            [nextChar notNil 
-             and:[nextChar isLetterOrDigit 
-                  or:[nextChar == $_ and:[allowUnderscoreInIdentifier]]
-                 ]
-            ] whileTrue:[
-                nextChar == $_ ifTrue:[
-                    part := nil.
-                ] ifFalse:[
-                    part := source nextAlphaNumericWord.
-                ].
-                part notNil ifTrue:[
-                    string := string , part.
-                ].
-                nextChar := source peek.
-
-                allowUnderscoreInIdentifier == true ifTrue:[
-                    nextChar == $_ ifTrue:[
-                        self warnUnderscoreAt:source position1Based.
-                    ].
-                    [nextChar == $_] whileTrue:[
-                        string := string copyWith:nextChar.
-                        nextChar := source nextPeek.
-                        (nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[
-                            string := string , source nextAlphaNumericWord.
-                            nextChar := source peek.
-                        ]
-                    ].
-                ].
-                (nextChar == $:) ifFalse:[
-                    self markSymbolFrom:tokenPosition to:(source position1Based-1).
-                    tokenValue := token := string asSymbol.
-                    tokenType := #Symbol.
-                    ^ tokenType
-                ].
-                string := string copyWith:nextChar.
-                nextChar := source nextPeek.
-                parserFlags allowLiteralNameSpaceSymbols ifTrue:[
-                    (nextChar == $:) ifTrue:[
-                        string := string copyWith:nextChar.
-                        nextChar := source nextPeek.
-                        isNameSpaceSymbol := true.      
-                    ].
-                ].
-            ].                   
-            tokenValue := token := string asSymbol.
-            tokenType := #Symbol.
-            ^ tokenType
-        ].
         (nextChar == $( ) ifTrue:[
             source next.
             token := '#('.
@@ -2111,6 +2059,7 @@
                     ^ tokenType
                 ].
             ].
+
             nextChar == $[ ifTrue:[
                 source next.    
                 token := '##('.
@@ -2118,11 +2067,28 @@
                 ^ tokenType
             ].
 
+            parserFlags allowVisualAgeESSymbolLiterals == true ifTrue:[
+                (self nextSymbolAfterHash) notNil ifTrue:[
+                    tokenType := #ESSymbol.
+                    ^ #ESSymbol
+                ].
+                (nextChar == $') ifTrue:[
+                    source next.    
+                    self nextString.
+                    tokenType := #ESSymbol.
+                    ^ #ESSymbol
+                ].
+            ].
+
             token := '##'.
             tokenType := #HashHash.
             ^ tokenType
         ].
 
+        (self nextSymbolAfterHash) notNil ifTrue:[
+            ^ #Symbol
+        ].
+
         ((typeArray at:(nextChar codePoint)) == #special) ifTrue:[
             string := source next asString.
             nextChar := source peek.
@@ -2664,6 +2630,70 @@
     "Modified: / 31.3.1998 / 17:33:14 / cg"
 !
 
+nextSymbolAfterHash
+    "helper: a # has been read - return #Symbol token or nil"
+
+    |nextChar string part isNameSpaceSymbol allowUnderscoreInIdentifier|
+
+    nextChar := source peek.
+    nextChar isNil ifTrue:[^ nil].
+
+    allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier.
+    isNameSpaceSymbol := false.
+
+    (nextChar isLetter
+    or:[(nextChar == $_) and:[allowUnderscoreInIdentifier]]) ifFalse:[^ nil].
+
+    string := ''.
+    [nextChar notNil 
+     and:[nextChar isLetterOrDigit 
+          or:[nextChar == $_ and:[allowUnderscoreInIdentifier]]
+         ]
+    ] whileTrue:[
+        nextChar == $_ ifTrue:[
+            part := nil.
+        ] ifFalse:[
+            part := source nextAlphaNumericWord.
+        ].
+        part notNil ifTrue:[
+            string := string , part.
+        ].
+        nextChar := source peek.
+
+        allowUnderscoreInIdentifier == true ifTrue:[
+            nextChar == $_ ifTrue:[
+                self warnUnderscoreAt:source position1Based.
+            ].
+            [nextChar == $_] whileTrue:[
+                string := string copyWith:nextChar.
+                nextChar := source nextPeek.
+                (nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[
+                    string := string , source nextAlphaNumericWord.
+                    nextChar := source peek.
+                ]
+            ].
+        ].
+        (nextChar == $:) ifFalse:[
+            self markSymbolFrom:tokenPosition to:(source position1Based-1).
+            tokenValue := token := string asSymbol.
+            tokenType := #Symbol.
+            ^ tokenType
+        ].
+        string := string copyWith:nextChar.
+        nextChar := source nextPeek.
+        parserFlags allowLiteralNameSpaceSymbols ifTrue:[
+            (nextChar == $:) ifTrue:[
+                string := string copyWith:nextChar.
+                nextChar := source nextPeek.
+                isNameSpaceSymbol := true.      
+            ].
+        ].
+    ].                   
+    tokenValue := token := string asSymbol.
+    tokenType := #Symbol.
+    ^ tokenType
+!
+
 nextToken
     "return the next token from the source-stream"
 
@@ -3010,7 +3040,7 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.208 2006-01-25 10:08:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.209 2006-02-03 16:16:49 cg Exp $'
 ! !
 
 Scanner initialize!