Scanner.st
changeset 709 b4351947a598
parent 708 11837544357d
child 714 09f35b01bbcf
equal deleted inserted replaced
708:11837544357d 709:b4351947a598
     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:'typeArray actionArray source lineNr
    14 	instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition
    15 	        token tokenType tokenPosition
       
    16 		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
    15 		tokenValue tokenName tokenLineNr hereChar peekChar peekChar2
    17 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
    16 		requestor exitBlock errorFlag ignoreErrors ignoreWarnings
    18 		saveComments currentComments collectedSource
    17 		saveComments currentComments collectedSource
    19 		allowUnderscoreInIdentifier allowDollarInIdentifier warnSTXSpecialComment
    18 		allowUnderscoreInIdentifier allowDollarInIdentifier
    20 		warnUnderscoreInIdentifier warnOldStyleAssignment
    19 		warnSTXSpecialComment warnUnderscoreInIdentifier
    21 		warnCommonMistakes outStream outCol warnSTXNameSpaceUse
    20 		warnOldStyleAssignment warnCommonMistakes outStream outCol
    22 		warnPossibleIncompatibilities warnDollarInIdentifier'
    21 		warnSTXNameSpaceUse warnPossibleIncompatibilities
       
    22 		warnDollarInIdentifier'
    23 	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
    23 	classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings
    24 		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
    24 		WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier
    25 		WarnCommonMistakes WarnPossibleIncompatibilities
    25 		WarnCommonMistakes WarnPossibleIncompatibilities
    26 		WarnDollarInIdentifier AllowDollarInIdentifier'
    26 		WarnDollarInIdentifier AllowDollarInIdentifier'
    27 	poolDictionaries:''
    27 	poolDictionaries:''
   606     "Created: / 1.4.1998 / 12:58:42 / cg"
   606     "Created: / 1.4.1998 / 12:58:42 / cg"
   607 ! !
   607 ! !
   608 
   608 
   609 !Scanner methodsFor:'error handling'!
   609 !Scanner methodsFor:'error handling'!
   610 
   610 
       
   611 correctableError:message position:pos1 to:pos2
       
   612     "report an error which can be corrected by compiler -
       
   613      return true if correction is wanted"
       
   614 
       
   615     |correctIt|
       
   616 
       
   617     requestor isNil ifTrue:[
       
   618 	self showErrorMessage:message position:pos1.
       
   619 	correctIt := false
       
   620     ] ifFalse:[
       
   621 	correctIt := requestor correctableError:message position:pos1 to:pos2 from:self
       
   622     ].
       
   623     correctIt ifFalse:[
       
   624 	exitBlock notNil ifTrue:[exitBlock value]
       
   625     ].
       
   626     ^ correctIt
       
   627 
       
   628     "Created: / 13.5.1998 / 16:45:56 / cg"
       
   629 !
       
   630 
   611 lastTokenLineNumber
   631 lastTokenLineNumber
   612     "return the line number of the token which was just read."
   632     "return the line number of the token which was just read."
   613 
   633 
   614     ^ tokenLineNr
   634     ^ tokenLineNr
   615 
   635 
   646 	    ^ false
   666 	    ^ false
   647 	].
   667 	].
   648 	^ requestor warning:aMessage position:position to:endPos from:self
   668 	^ requestor warning:aMessage position:position to:endPos from:self
   649     ].
   669     ].
   650     ^ false
   670     ^ false
       
   671 !
       
   672 
       
   673 parseError:aMessage
       
   674     "report an error"
       
   675 
       
   676     ^ self parseError:aMessage position:tokenPosition to:nil
       
   677 
       
   678     "Created: / 13.5.1998 / 16:45:13 / cg"
       
   679 !
       
   680 
       
   681 parseError:aMessage position:position
       
   682     "report an error"
       
   683 
       
   684     ^ self parseError:aMessage position:position to:nil
       
   685 
       
   686     "Created: / 13.5.1998 / 16:45:05 / cg"
       
   687 !
       
   688 
       
   689 parseError:aMessage position:position to:endPos
       
   690     "report an error"
       
   691 
       
   692     |m|
       
   693 
       
   694     errorFlag := true.
       
   695     m := 'Error: ' , aMessage.
       
   696     self notifyError:m position:position to:endPos.
       
   697     exitBlock notNil ifTrue:[exitBlock value].
       
   698     ^ false
       
   699 
       
   700     "Created: / 13.5.1998 / 16:44:55 / cg"
   651 !
   701 !
   652 
   702 
   653 showErrorMessage:aMessage position:pos
   703 showErrorMessage:aMessage position:pos
   654     "show an errormessage on the Transcript"
   704     "show an errormessage on the Transcript"
   655 
   705 
  1742 ! !
  1792 ! !
  1743 
  1793 
  1744 !Scanner class methodsFor:'documentation'!
  1794 !Scanner class methodsFor:'documentation'!
  1745 
  1795 
  1746 version
  1796 version
  1747     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.81 1998-05-13 13:50:13 cg Exp $'
  1797     ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.82 1998-05-13 17:58:56 cg Exp $'
  1748 ! !
  1798 ! !
  1749 Scanner initialize!
  1799 Scanner initialize!