#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Mon, 11 Feb 2019 12:29:51 +0100
changeset 4345 e252e163a32c
parent 4344 900b7b7a648e
child 4346 1023a1792e57
#FEATURE by cg class: Scanner added: #escapeCharacterFor:escapeStyle: removed: #escapeCharacterFor: changed: #nextIdentifier #nextString:escapeStyle:
Scanner.st
--- a/Scanner.st	Sun Feb 10 22:39:34 2019 +0100
+++ b/Scanner.st	Mon Feb 11 12:29:51 2019 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -145,7 +143,7 @@
 extendedBinarySelectorCharacters
     "return a collection of characters which are optionally allowed in binary selectors"
 
-    "/ ^ '±×·÷«»'.
+    "/ ^ '±×·÷«»'.
     ^ String
 	with:(Character value:16rB1)  "/ plus-minus
 	with:(Character value:16rD7)  "/ times
@@ -1834,13 +1832,13 @@
 !
 
 warnParagraphAt:position
-    "warn about §-character in an identifier"
+    "warn about §-character in an identifier"
 
     ignoreWarnings ifFalse:[
 	"/ didWarnAboutParagraphInIdentifier ifFalse:[
 	    parserFlags warnParagraphInIdentifier ifTrue:[
 		self
-		    warning:'§-characters in identifiers/symbols are nonportable'
+		    warning:'§-characters in identifiers/symbols are nonportable'
 		    doNotShowAgainAction:[ ParserFlags warnParagraphInIdentifier:false ]
 		    position:position to:position.
 		"
@@ -2371,9 +2369,15 @@
     "Created: / 14-03-2011 / 14:11:46 / cg"
 !
 
-escapeCharacterFor:aCharacter
+escapeCharacterFor:aCharacter escapeStyle:escapeStyle
     "only if AllowExtendedSTXSyntax is true
-     For now: do not use, since stc does not support it.
+     For now: only use c-style, since stc does not support others.
+        'c' - C-style escapes: 
+                        \n,\t,\r,\b,\xXX,\uXXXX,\UXXXXXX,
+        'x' - extended-style escapes:
+                        as yet unsupported
+        'r' - regex
+                        as yet unsupported
 
      much like character escapes in C-literals;
      expands:
@@ -2403,6 +2407,7 @@
     aCharacter == $g ifTrue:[^ Character bell].
     aCharacter == $0 ifTrue:[^ Character null].
     aCharacter == $\ ifTrue:[^ aCharacter].
+
     aCharacter == $< ifTrue:[
         pos1 := source position.
         name := ''.
@@ -2482,7 +2487,7 @@
      ParserFlags allowExtendedSTXSyntax:false
     "
 
-    "Modified: / 08-02-2019 / 21:58:55 / Claus Gittinger"
+    "Created: / 11-02-2019 / 12:27:25 / Claus Gittinger"
 !
 
 ignoreErrors
@@ -2940,12 +2945,12 @@
     ((nextChar == $') 
     and:[ (string size == 1)
     and:[ parserFlags allowCStrings ]]) ifTrue:[
-        ^ self nextString:$' escapeStyle:#c
+        ^ self nextString:$' escapeStyle:string
     ].    
 
     (((nextChar == $_) and:[allowUnderscoreInIdentifier])
     or:[ (allowDollarInIdentifier and:[nextChar == $$ ])
-    or:[ (nextChar == $§ and:[ parserFlags allowParagraphInIdentifier])
+    or:[ (nextChar == $§ and:[ parserFlags allowParagraphInIdentifier])
     or:[ allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]]]]]) ifTrue:[
         pos := source position + 1.
         nextChar == $_ ifTrue:[
@@ -2954,7 +2959,7 @@
             nextChar == $$ ifTrue:[
                 self warnDollarAt:pos.
             ] ifFalse:[
-                nextChar == $§ ifTrue:[
+                nextChar == $§ ifTrue:[
                     self warnParagraphAt:pos.
                 ] ifFalse:[
                     "/ self warnNationalCharacterAt:pos.
@@ -2974,7 +2979,7 @@
                 ].
                 ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier])
                       or:[((nextChar == $$ ) and:[allowDollarInIdentifier])
-                      or:[((nextChar == $§ ) and:[parserFlags allowParagraphInIdentifier])
+                      or:[((nextChar == $§ ) and:[parserFlags allowParagraphInIdentifier])
                       or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]].
             ]
         ].
@@ -3039,7 +3044,7 @@
 
     "Created: / 13-09-1995 / 12:56:42 / claus"
     "Modified: / 17-11-2016 / 09:19:46 / cg"
-    "Modified: / 08-02-2019 / 19:09:51 / Claus Gittinger"
+    "Modified: / 11-02-2019 / 12:25:36 / Claus Gittinger"
 !
 
 nextMantissa:radix
@@ -3388,10 +3393,13 @@
     "a quote has been scanned; scan the string (caring for doubled quotes).
      escapeStyle may be:
         nil - old style ST80 strings (no character escapes)
-        #c  - C-style escapes: 
+        'c' - C-style escapes: 
                         \n,\t,\r,\b,\xXX,\uXXXX,\UXXXXXX,
-        #x  - extended-style escapes: 
-                        c-style PLUS \<nul>,\<...>
+        'x' - extended-style escapes:
+                        as yet unsupported
+        'r' - regex
+                        as yet unsupported
+
     "
 
     |nextChar string pos
@@ -3431,7 +3439,7 @@
                         peekChar := source peekOrNil.
                         peekChar notNil ifTrue:[
                             source next.
-                            nextChar := self escapeCharacterFor:peekChar.
+                            nextChar := self escapeCharacterFor:peekChar escapeStyle:escapeStyle.
                         ]
                     ]
                 ]
@@ -3464,6 +3472,7 @@
     ^ tokenType
 
     "Created: / 08-02-2019 / 19:07:57 / Claus Gittinger"
+    "Modified (comment): / 11-02-2019 / 12:28:24 / Claus Gittinger"
 !
 
 nextSymbolAfterHash
@@ -3721,7 +3730,7 @@
 		].
 		"/ a nil token means: continue reading
 	    ] ifFalse:[
-		(ch == $§ and:[parserFlags allowParagraphInIdentifier]) ifTrue:[
+		(ch == $§ and:[parserFlags allowParagraphInIdentifier]) ifTrue:[
 		    tok := self nextIdentifier.
 		    tok notNil ifTrue:[
 			^ tok