silently scan Foo.Bar as Foo::Bar,
authorClaus Gittinger <cg@exept.de>
Mon, 31 Jan 2000 21:00:28 +0100
changeset 1027 c944d9be2a69
parent 1026 831aa102111f
child 1028 cbdce68d87f6
silently scan Foo.Bar as Foo::Bar, when AllowQualifiedNames is on.
Scanner.st
--- a/Scanner.st	Mon Jan 31 20:26:02 2000 +0100
+++ b/Scanner.st	Mon Jan 31 21:00:28 2000 +0100
@@ -1295,7 +1295,7 @@
     peekChar == $: ifTrue:[
         source next.
         peekChar := nil.
-        tokenType := token :=#'::'.
+        tokenType := token := #'::'.
         ^ tokenType
     ].
 
@@ -1457,7 +1457,7 @@
     "an alpha character (or underscor if AllowUnderscore) has been read.
      Return the next identifier."
 
-    |nextChar string ok pos|
+    |nextChar string ok pos ch2|
 
     hereChar == $_ ifTrue:[
         "/
@@ -1524,8 +1524,10 @@
 
     (nextChar == $: and:[scanColonAsKeyword]) ifTrue:[
         source next.
-        (source peekOrNil == $=) ifFalse:[
-            (source peekOrNil == $:) ifFalse:[
+        ch2 := source peekOrNil.
+        "/ colon follows - care for '::' (nameSpace separator) or ':=' (assignment)
+        (ch2 == $=) ifFalse:[
+            (ch2 == $:) ifFalse:[
                 tokenName := token := string copyWith:nextChar.
                 tokenType := #Keyword.
                 ^ self
@@ -1536,6 +1538,18 @@
             peekChar := $:.
             peekChar2 := $=.
         ]
+    ] ifFalse:[
+        (nextChar == $. and:[AllowQualifiedNames]) ifTrue:[
+            "/ period follows - if next-after character is an identifier character,
+            "/ make peekSym a #NameSpaceSeparator; otherwise a $.
+            source next.
+            ch2 := source peekOrNil.
+            (ch2 isLetter or:[ch2 == $_ and:[AllowUnderscoreInIdentifier]]) ifTrue:[
+                peekChar := #'::'.
+            ] ifFalse:[
+                peekChar := $.
+            ].
+        ].
     ].
 
     nextChar == $- ifTrue:[
@@ -1830,6 +1844,15 @@
 
     [true] whileTrue:[
         peekChar notNil ifTrue:[
+            "/ kludge - should be called peekSym.
+            "/ used when xlating Foo.Bar into Foo::Bar
+            peekChar isSymbol ifTrue:[
+                token := nil.
+                tokenType := peekChar.
+                peekChar := nil.
+                ^ tokenType
+            ].
+
             peekChar isSeparator ifTrue:[
                 peekChar == (Character cr) ifTrue:[
                     lineNr := lineNr + 1.
@@ -1903,7 +1926,9 @@
         actionBlock := actionArray at:v.
         actionBlock notNil ifTrue:[
             tok := actionBlock value:self value:ch.
-            tok notNil ifTrue:[^ tok].
+            tok notNil ifTrue:[
+                ^ tok
+            ].
         ] ifFalse:[
             self syntaxError:('invalid character: ''' , ch asString , ''' ',
                               '(' , v printString , ')')
@@ -2076,6 +2101,6 @@
 !Scanner class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.116 2000-01-31 19:26:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.117 2000-01-31 20:00:28 cg Exp $'
 ! !
 Scanner initialize!