Scanner.st
changeset 1073 d6041f6d680c
parent 1029 aeaed53633d9
child 1074 5539425b66f2
equal deleted inserted replaced
1072:99bd12c0fe76 1073:d6041f6d680c
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     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 
       
    13 "{ Package: 'stx:libcomp' }"
    12 
    14 
    13 Object subclass:#Scanner
    15 Object subclass:#Scanner
    14 	instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition
    16 	instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition
    15 		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
    17 		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
    16 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
    18 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
   796     ^ correctIt
   798     ^ correctIt
   797 
   799 
   798     "Created: / 19.1.2000 / 16:28:03 / cg"
   800     "Created: / 19.1.2000 / 16:28:03 / cg"
   799 !
   801 !
   800 
   802 
       
   803 errorMessagePrefix
       
   804     ^ 'Error:'
       
   805 !
       
   806 
   801 lastTokenLineNumber
   807 lastTokenLineNumber
   802     "return the line number of the token which was just read."
   808     "return the line number of the token which was just read."
   803 
   809 
   804     ^ tokenLineNr
   810     ^ tokenLineNr
   805 
   811 
   860     "report an error"
   866     "report an error"
   861 
   867 
   862     |m|
   868     |m|
   863 
   869 
   864     errorFlag := true.
   870     errorFlag := true.
   865     m := 'Error: ' , (aMessage ? '???').
   871     m := (self errorMessagePrefix) , ' ' , (aMessage ? '???').
   866     self notifyError:m position:position to:endPos.
   872     self notifyError:m position:position to:endPos.
   867     exitBlock notNil ifTrue:[exitBlock value].
   873     exitBlock notNil ifTrue:[exitBlock value].
   868     ^ false
   874     ^ false
   869 
   875 
   870     "Created: / 13.5.1998 / 16:44:55 / cg"
   876     "Created: / 13.5.1998 / 16:44:55 / cg"
   896 !
   902 !
   897 
   903 
   898 syntaxError:aMessage position:position to:endPos
   904 syntaxError:aMessage position:position to:endPos
   899     "a syntax error happened"
   905     "a syntax error happened"
   900 
   906 
   901     self notifyError:('Error:' , aMessage) position:position to:endPos.
   907     self notifyError:((self errorMessagePrefix) , ' ' , aMessage) position:position to:endPos.
   902     exitBlock notNil ifTrue:[exitBlock value].
   908     exitBlock notNil ifTrue:[exitBlock value].
   903     ^ false
   909     ^ false
   904 !
   910 !
   905 
   911 
   906 warnCommonMistake:msg at:position
   912 warnCommonMistake:msg at:position
  1009 !
  1015 !
  1010 
  1016 
  1011 warning:aMessage position:position to:endPos
  1017 warning:aMessage position:position to:endPos
  1012     "a warning"
  1018     "a warning"
  1013 
  1019 
  1014     ^ self notifyWarning:('Warning: ' , aMessage) position:position to:endPos
  1020     ^ self notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) position:position to:endPos
       
  1021 !
       
  1022 
       
  1023 warningMessagePrefix
       
  1024     ^ 'Warning:'
  1015 ! !
  1025 ! !
  1016 
  1026 
  1017 !Scanner methodsFor:'general scanning'!
  1027 !Scanner methodsFor:'general scanning'!
  1018 
  1028 
  1019 scanNumberFrom:aStringOrStream
  1029 scanNumberFrom:aStringOrStream
  2100 ! !
  2110 ! !
  2101 
  2111 
  2102 !Scanner class methodsFor:'documentation'!
  2112 !Scanner class methodsFor:'documentation'!
  2103 
  2113 
  2104 version
  2114 version
  2105     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.118 2000-02-01 11:23:54 cg Exp $'
  2115     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.119 2000-08-23 11:39:28 cg Exp $'
  2106 ! !
  2116 ! !
  2107 Scanner initialize!
  2117 Scanner initialize!