Scanner.st
changeset 4433 ad2645bee258
parent 4432 fef0c840421e
child 4438 bd363f7ca282
equal deleted inserted replaced
4432:fef0c840421e 4433:ad2645bee258
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   143 !
   141 !
   144 
   142 
   145 extendedBinarySelectorCharacters
   143 extendedBinarySelectorCharacters
   146     "return a collection of characters which are optionally allowed in binary selectors"
   144     "return a collection of characters which are optionally allowed in binary selectors"
   147 
   145 
   148     "/ ^ '±×·÷«»'.
   146     "/ ^ '±×·÷«»'.
   149     ^ String
   147     ^ String
   150 	with:(Character value:16rB1)  "/ plus-minus
   148 	with:(Character value:16rB1)  "/ plus-minus
   151 	with:(Character value:16rD7)  "/ times
   149 	with:(Character value:16rD7)  "/ times
   152 	with:(Character value:16rB7)  "/ centered dot
   150 	with:(Character value:16rB7)  "/ centered dot
   153 	with:(Character value:16rF7)  "/ divide
   151 	with:(Character value:16rF7)  "/ divide
  1856 
  1854 
  1857     "Modified: 23.5.1997 / 12:16:48 / cg"
  1855     "Modified: 23.5.1997 / 12:16:48 / cg"
  1858 !
  1856 !
  1859 
  1857 
  1860 warnParagraphAt:position
  1858 warnParagraphAt:position
  1861     "warn about §-character in an identifier"
  1859     "warn about §-character in an identifier"
  1862 
  1860 
  1863     ignoreWarnings ifFalse:[
  1861     ignoreWarnings ifFalse:[
  1864 	"/ didWarnAboutParagraphInIdentifier ifFalse:[
  1862 	"/ didWarnAboutParagraphInIdentifier ifFalse:[
  1865 	    parserFlags warnParagraphInIdentifier ifTrue:[
  1863 	    parserFlags warnParagraphInIdentifier ifTrue:[
  1866 		self
  1864 		self
  1867 		    warning:'§-characters in identifiers/symbols are nonportable'
  1865 		    warning:'§-characters in identifiers/symbols are nonportable'
  1868 		    doNotShowAgainAction:[ ParserFlags warnParagraphInIdentifier:false ]
  1866 		    doNotShowAgainAction:[ ParserFlags warnParagraphInIdentifier:false ]
  1869 		    position:position to:position.
  1867 		    position:position to:position.
  1870 		"
  1868 		"
  1871 		 only warn once (per method)
  1869 		 only warn once (per method)
  1872 		"
  1870 		"
  2965         "/ no need to check for allowUnderscoreInIdentifier here;
  2963         "/ no need to check for allowUnderscoreInIdentifier here;
  2966         "/ could not arrive here if it was off
  2964         "/ could not arrive here if it was off
  2967         "/
  2965         "/
  2968         nextChar := source nextPeek.
  2966         nextChar := source nextPeek.
  2969         parserFlags allowOldStyleAssignment ifTrue:[
  2967         parserFlags allowOldStyleAssignment ifTrue:[
  2970             (nextChar notNil and:[ nextChar isLetterOrDigit or:[nextChar == $_]]) ifFalse:[
  2968             (nextChar notNil and:[ nextChar isLetterOrDigitOrUnderline]) ifFalse:[
  2971                 "oops: a single underscore is an old-style assignement"
  2969                 "oops: a single underscore is an old-style assignement"
  2972                 nextChar == $: ifFalse:[
  2970                 nextChar == $: ifFalse:[
  2973                     self warnOldStyleAssignmentAt:tokenPosition.
  2971                     self warnOldStyleAssignmentAt:tokenPosition.
  2974                     tokenType := token := $_.
  2972                     tokenType := token := $_.
  2975                     ^ tokenType
  2973                     ^ tokenType
  3006         ^ self xnextString:$' escapeStyle:string
  3004         ^ self xnextString:$' escapeStyle:string
  3007     ].    
  3005     ].    
  3008 
  3006 
  3009     (((nextChar == $_) and:[allowUnderscoreInIdentifier])
  3007     (((nextChar == $_) and:[allowUnderscoreInIdentifier])
  3010     or:[ (allowDollarInIdentifier and:[nextChar == $$ ])
  3008     or:[ (allowDollarInIdentifier and:[nextChar == $$ ])
  3011     or:[ (nextChar == $§ and:[ parserFlags allowParagraphInIdentifier])
  3009     or:[ (nextChar == $§ and:[ parserFlags allowParagraphInIdentifier])
  3012     or:[ allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]]]]]) ifTrue:[
  3010     or:[ allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]]]]]) ifTrue:[
  3013         pos := source position + 1.
  3011         pos := source position + 1.
  3014         nextChar == $_ ifTrue:[
  3012         nextChar == $_ ifTrue:[
  3015             self warnUnderscoreAt:pos.
  3013             self warnUnderscoreAt:pos.
  3016         ] ifFalse:[
  3014         ] ifFalse:[
  3017             nextChar == $$ ifTrue:[
  3015             nextChar == $$ ifTrue:[
  3018                 self warnDollarAt:pos.
  3016                 self warnDollarAt:pos.
  3019             ] ifFalse:[
  3017             ] ifFalse:[
  3020                 nextChar == $§ ifTrue:[
  3018                 nextChar == $§ ifTrue:[
  3021                     self warnParagraphAt:pos.
  3019                     self warnParagraphAt:pos.
  3022                 ] ifFalse:[
  3020                 ] ifFalse:[
  3023                     "/ self warnNationalCharacterAt:pos.
  3021                     "/ self warnNationalCharacterAt:pos.
  3024                 ]
  3022                 ]
  3025             ]
  3023             ]
  3035                     string := string , source nextAlphaNumericWord.
  3033                     string := string , source nextAlphaNumericWord.
  3036                     nextChar := source peekOrNil.
  3034                     nextChar := source peekOrNil.
  3037                 ].
  3035                 ].
  3038                 ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier])
  3036                 ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier])
  3039                       or:[((nextChar == $$ ) and:[allowDollarInIdentifier])
  3037                       or:[((nextChar == $$ ) and:[allowDollarInIdentifier])
  3040                       or:[((nextChar == $§ ) and:[parserFlags allowParagraphInIdentifier])
  3038                       or:[((nextChar == $§ ) and:[parserFlags allowParagraphInIdentifier])
  3041                       or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]].
  3039                       or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]].
  3042             ]
  3040             ]
  3043         ].
  3041         ].
  3044     ].
  3042     ].
  3045 
  3043 
  3100     ].
  3098     ].
  3101     ^ tokenType
  3099     ^ tokenType
  3102 
  3100 
  3103     "Created: / 13-09-1995 / 12:56:42 / claus"
  3101     "Created: / 13-09-1995 / 12:56:42 / claus"
  3104     "Modified: / 17-11-2016 / 09:19:46 / cg"
  3102     "Modified: / 17-11-2016 / 09:19:46 / cg"
  3105     "Modified: / 03-06-2019 / 11:14:55 / Claus Gittinger"
  3103     "Modified: / 05-06-2019 / 17:06:34 / Claus Gittinger"
  3106 !
  3104 !
  3107 
  3105 
  3108 nextMantissa:radix
  3106 nextMantissa:radix
  3109     "read the mantissa of a radix number"
  3107     "read the mantissa of a radix number"
  3110 
  3108 
  3739 		tok notNil ifTrue:[
  3737 		tok notNil ifTrue:[
  3740 		    ^ tok
  3738 		    ^ tok
  3741 		].
  3739 		].
  3742 		"/ a nil token means: continue reading
  3740 		"/ a nil token means: continue reading
  3743 	    ] ifFalse:[
  3741 	    ] ifFalse:[
  3744 		(ch == $§ and:[parserFlags allowParagraphInIdentifier]) ifTrue:[
  3742 		(ch == $§ and:[parserFlags allowParagraphInIdentifier]) ifTrue:[
  3745 		    tok := self nextIdentifier.
  3743 		    tok := self nextIdentifier.
  3746 		    tok notNil ifTrue:[
  3744 		    tok notNil ifTrue:[
  3747 			^ tok
  3745 			^ tok
  3748 		    ].
  3746 		    ].
  3749 		    "/ a nil token means: continue reading
  3747 		    "/ a nil token means: continue reading