Scanner.st
changeset 311 1fcbd4311698
parent 310 27ed956b591e
child 313 ee72a11af9a2
equal deleted inserted replaced
310:27ed956b591e 311:1fcbd4311698
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 Object subclass:#Scanner
    13 Object subclass:#Scanner
    14 	instanceVariableNames:'source lineNr collectedSource token tokenType tokenPosition tokenValue
    14 	instanceVariableNames:'source lineNr collectedSource token tokenType tokenPosition
    15 		tokenName tokenLineNr tokenRadix hereChar peekChar peekChar2
    15 		tokenValue tokenName tokenLineNr tokenRadix hereChar peekChar
    16 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
    16 		peekChar2 requestor exitBlock errorFlag ignoreErrors
    17 		saveComments currentComments warnSTXSpecialComment
    17 		ignoreWarnings saveComments currentComments warnSTXSpecialComment
    18 		warnUnderscoreInIdentifier warnOldStyleAssignment warnCommonMistakes
    18 		warnUnderscoreInIdentifier warnOldStyleAssignment
    19 		outStream
    19 		warnCommonMistakes outStream outCol'
    20 		outCol'
       
    21 	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
    20 	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
    22 		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
    21 		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
    23 		WarnCommonMistakes'
    22 		WarnCommonMistakes'
    24 	poolDictionaries:''
    23 	poolDictionaries:''
    25 	category:'System-Compiler'
    24 	category:'System-Compiler'
    26 !
    25 !
    27 
    26 
    28 !Scanner class methodsFor:'documentation'!
    27 !Scanner  class methodsFor:'documentation'!
    29 
    28 
    30 copyright
    29 copyright
    31 "
    30 "
    32  COPYRIGHT (c) 1989 by Claus Gittinger
    31  COPYRIGHT (c) 1989 by Claus Gittinger
    33 	      All Rights Reserved
    32 	      All Rights Reserved
    51     (to me, these seem to be internal private methods; their public use
    50     (to me, these seem to be internal private methods; their public use
    52      is not a good idea ..)
    51      is not a good idea ..)
    53 "
    52 "
    54 ! !
    53 ! !
    55 
    54 
    56 !Scanner class methodsFor:'initialization'!
    55 !Scanner  class methodsFor:'initialization'!
    57 
    56 
    58 initialize
    57 initialize
    59     Warnings := true.
    58     Warnings := true.
    60     WarnSTXSpecials := true.
    59     WarnSTXSpecials := true.
    61     WarnUnderscoreInIdentifier := true.
    60     WarnUnderscoreInIdentifier := true.
   112     "
   111     "
   113      Scanner setupActions
   112      Scanner setupActions
   114     "
   113     "
   115 ! !
   114 ! !
   116 
   115 
   117 !Scanner class methodsFor:'instance creation'!
   116 !Scanner  class methodsFor:'instance creation'!
   118 
   117 
   119 for:aStringOrStream
   118 for:aStringOrStream
   120     "return a new scanner reading from aStringOrStream"
   119     "return a new scanner reading from aStringOrStream"
   121 
   120 
   122     ^ (super new) initializeFor:aStringOrStream
   121     ^ (super new) initializeFor:aStringOrStream
   123 ! !
   122 ! !
   124 
   123 
   125 !Scanner class methodsFor:'defaults'!
   124 !Scanner  class methodsFor:'defaults'!
   126 
   125 
   127 allowUnderscoreInIdentifier
   126 allowUnderscoreInIdentifier
   128     "return true, if underscores are allowed in identifiers"
   127     "return true, if underscores are allowed in identifiers"
   129 
   128 
   130     ^ AllowUnderscoreInIdentifier
   129     ^ AllowUnderscoreInIdentifier
   409     exitBlock notNil ifTrue:[exitBlock value].
   408     exitBlock notNil ifTrue:[exitBlock value].
   410     ^ false
   409     ^ false
   411 !
   410 !
   412 
   411 
   413 warnCommonMistake:msg at:position
   412 warnCommonMistake:msg at:position
       
   413     self warnCommonMistake:msg position:position to:position
       
   414 
       
   415     "Modified: 18.7.1996 / 10:28:53 / cg"
       
   416 !
       
   417 
       
   418 warnCommonMistake:msg position:pos1 to:pos2
   414     ignoreWarnings ifFalse:[
   419     ignoreWarnings ifFalse:[
   415 	warnCommonMistakes ifTrue:[
   420         warnCommonMistakes ifTrue:[
   416 	    self 
   421             self 
   417 		warning:msg
   422                 warning:msg
   418 		position:position to:position.
   423                 position:pos1 to:pos2.
   419 	]
   424         ]
   420     ]
   425     ]
       
   426 
       
   427     "Created: 18.7.1996 / 10:28:38 / cg"
   421 !
   428 !
   422 
   429 
   423 warnOldStyleAssignmentAt:position
   430 warnOldStyleAssignmentAt:position
   424     ignoreWarnings ifFalse:[
   431     ignoreWarnings ifFalse:[
   425 	warnOldStyleAssignment ifTrue:[
   432 	warnOldStyleAssignment ifTrue:[
  1175     saveComments ifTrue:[
  1182     saveComments ifTrue:[
  1176 	self endComment:commentStream contents.
  1183 	self endComment:commentStream contents.
  1177     ].
  1184     ].
  1178 ! !
  1185 ! !
  1179 
  1186 
  1180 !Scanner class methodsFor:'documentation'!
  1187 !Scanner  class methodsFor:'documentation'!
  1181 
  1188 
  1182 version
  1189 version
  1183     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.47 1996-07-18 08:13:34 cg Exp $'
  1190     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.48 1996-07-18 08:33:49 cg Exp $'
  1184 ! !
  1191 ! !
  1185 Scanner initialize!
  1192 Scanner initialize!