Scanner.st
branchjv
changeset 4666 903315d3cfb8
parent 4660 ded36b294a2a
child 4727 36bdabdd6495
--- a/Scanner.st	Mon Jun 28 10:40:16 2021 +0100
+++ b/Scanner.st	Thu Jun 24 18:04:31 2021 +0100
@@ -2411,6 +2411,26 @@
     ^ false
 !
 
+isIdentifierCharacter:nextChar
+    ^ nextChar isLetterOrDigit
+        or:[ (nextChar == $_ and:[parserFlags allowUnderscoreInIdentifier])
+        or:[ (parserFlags allowDollarInIdentifier and:[nextChar == $$ ])
+        or:[ (nextChar == $� and:[ parserFlags allowParagraphInIdentifier])
+        or:[ (parserFlags allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]])
+        or:[ false"/(parserFlags allowGreekCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]])
+        ]]]]]
+
+
+    "
+     self new isIdentifierCharacter:$a
+     self new isIdentifierCharacter:$2
+     self new isIdentifierCharacter:$_
+
+    "
+
+    "Created: / 30-04-2021 / 11:54:20 / Jan Vrany <jan.vrany@labware.com>"
+!
+
 isSpecialOrExtendedSpecialCharacter:ch
     |code charType|
 
@@ -2460,21 +2480,34 @@
 nextCharacter
     "a $ has been read - return a character token"
 
-    |nextChar t|
+    | nextChar t|
 
     source next.
     nextChar := source next.
     nextChar notNil ifTrue:[
-	t := nextChar.
-	tokenType := #Character.
+        t := nextChar.
+        tokenType := #Character.
+        "/ Following is to allow identifiers to start with $ (dollar)
+        (t isSeparator not and:[parserFlags allowDollarInIdentifier]) ifTrue: [
+            | nextNextChar |
+            nextNextChar := source peek.
+            (nextNextChar notNil and:[self isIdentifierCharacter: nextNextChar]) ifTrue: [
+                self nextIdentifier.
+                tokenType == #Identifier ifTrue: [
+                    token := tokenName := '$' , nextChar , token.
+                ].
+                ^ tokenType
+            ].
+        ].
     ] ifFalse:[
-	t := nil.
-	tokenType := #EOF
+        t := nil.
+        tokenType := #EOF
     ].
     tokenValue := token := t.
     ^ tokenType
 
-    "Modified: / 13.5.1998 / 15:09:50 / cg"
+    "Modified: / 13-05-1998 / 15:09:50 / cg"
+    "Modified: / 24-06-2021 / 17:03:51 / Jan Vrany <jan.vrany@labware.com>"
 !
 
 nextColonOrAssign
@@ -3899,6 +3932,11 @@
 
 version_CVS
     ^ '$Header$'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !