--- a/Scanner.st Thu Aug 24 13:59:16 2017 +0200
+++ b/Scanner.st Wed Aug 30 16:03:49 2017 +0200
@@ -3589,13 +3589,13 @@
anyNonBlank := false.
saveComments ifTrue:[
- commentStream := CharacterWriteStream on:''.
- self beginComment.
+ commentStream := CharacterWriteStream on:''.
+ self beginComment.
].
outStream notNil ifTrue:[
- outStream nextPut:Character doubleQuote.
- outCol := outCol + 1
+ outStream nextPut:Character doubleQuote.
+ outCol := outCol + 1
].
startPos := source position + 1.
@@ -3611,151 +3611,151 @@
(however, it is so convenient - I don't want to miss it)
"
(hereChar == $/ and:[parserFlags allowSTXEOLComments]) ifTrue:[
- hereChar := source nextPeek.
-
- self skipToEndOfLineRememberingIn:commentStream.
- endPos := source position.
- self markCommentFrom:startPos to:endPos+1.
- commentType := #eolComment.
- self warnSTXSpecialCommentAt:startPos to:endPos.
- outStream notNil ifTrue:[
- outStream cr.
- outCol := 1
- ].
- "skip cr"
- source next.
+ hereChar := source nextPeek.
+
+ self skipToEndOfLineRememberingIn:commentStream.
+ endPos := source position.
+ self markCommentFrom:startPos to:endPos+1.
+ commentType := #eolComment.
+ self warnSTXSpecialCommentAt:startPos to:endPos.
+ outStream notNil ifTrue:[
+ outStream cr.
+ outCol := 1
+ ].
+ "skip cr"
+ source next.
] ifFalse:[
- (hereChar == $< and:[parserFlags allowSTXDelimiterComments]) ifTrue:[
- hereChar := source nextPeek.
- (hereChar == $<) ifTrue:[
- "
- another special ST/X addition:
- a << right after the initial double quote makes it a token delimited comment,
- which continues up to a line starting with the token.
- This is very useful to comment out which contain any other type of comment.
- Since this is non-standard, you loose compatibility with other Smalltalks, if you use it.
- "
- commentStream notNil ifTrue:[
- commentStream nextPutAll:'<<'
- ].
- hereChar := source nextPeek.
-
- delimiter := String streamContents:[:s | self skipToEndOfLineRememberingIn:s].
- delimiter := delimiter withoutSeparators.
- delimiter isEmpty ifTrue:[
- self parseError:'invalid delimiter in comment'.
- ^ self
- ].
- ((delimiter first isLetterOrUnderline)
- and:[delimiter from:2 conform:[:ch | ch isLetterOrDigit]]) ifFalse:[
- "/ treat as regular comment
- commentType := #regularComment.
- source position:startPos.
- ] ifTrue:[
- hereChar == Character cr ifTrue:[
- hereChar := source nextPeek.
- ].
- commentStream notNil ifTrue:[
- commentStream nextPutLine:delimiter
- ].
- stillInComment := true.
- [stillInComment and:[hereChar notNil]] whileTrue:[
- line := String streamContents:[:s | self skipToEndOfLineRememberingIn:s].
- commentStream notNil ifTrue:[
- commentStream nextPutLine:line
- ].
- hereChar == Character cr ifTrue:[
- hereChar := source nextPeek.
- ].
- stillInComment := (line startsWith:delimiter) not.
- ].
- stillInComment ifTrue:[
- self markCommentFrom:startPos to:(source collectionSize).
- self warning:'unclosed comment' position:startPos to:(source position + 1)
- ].
- self markCommentFrom:startPos to:(source position + 1).
- commentType := #delimiterComment.
- ]
- ] ifFalse:[
- commentStream notNil ifTrue:[
- commentStream nextPut:$<
- ].
- ].
- ].
-
- (commentType == #regularComment) ifTrue:[
- hereChar == ${ ifTrue:[
- "
- special ST/X addition:
- a ${ right after the initial double quote starts a directive
- "
- self parseDirective
- ].
-
- stillInComment := true.
- [stillInComment] whileTrue:[
- stillInComment := false.
-
- [hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[
- hereChar isSeparator ifFalse:[ anyNonBlank := true ].
- hereChar == (Character cr) ifTrue:[
- lineNr := lineNr + 1.
- ].
- commentStream notNil ifTrue:[
- commentStream nextPut:hereChar
- ].
- outStream notNil ifTrue:[
- outStream nextPut:hereChar.
- outCol := outCol + 1
- ].
- hereChar := source nextPeek
- ].
-
- hereChar isNil ifTrue:[
- self markCommentFrom:startPos to:(source collectionSize).
- self warning:'unclosed comment' position:startPos to:(source position + 1)
- ] ifFalse:[
- self markCommentFrom:startPos to:(source position + 1).
- outStream notNil ifTrue:[
- outStream nextPut:(Character doubleQuote).
- outCol := outCol + 1
- ].
- ].
- endPos := source position.
- "skip final dQuote"
- source next.
-
- (source peek == Character doubleQuote) ifTrue:[
- stillInComment := true.
- hereChar := source nextPeek.
- ].
- ].
- ]
+ (hereChar == $< and:[parserFlags allowSTXDelimiterComments]) ifTrue:[
+ hereChar := source nextPeek.
+ (hereChar == $<) ifTrue:[
+ "
+ another special ST/X addition:
+ a << right after the initial double quote makes it a token delimited comment,
+ which continues up to a line starting with the token.
+ This is very useful to comment out which contain any other type of comment.
+ Since this is non-standard, you loose compatibility with other Smalltalks, if you use it.
+ "
+ commentStream notNil ifTrue:[
+ commentStream nextPutAll:'<<'
+ ].
+ hereChar := source nextPeek.
+
+ delimiter := String streamContents:[:s | self skipToEndOfLineRememberingIn:s].
+ delimiter := delimiter withoutSeparators.
+ delimiter isEmpty ifTrue:[
+ self parseError:'invalid delimiter in comment'.
+ ^ self
+ ].
+ ((delimiter first isLetterOrUnderline)
+ and:[delimiter from:2 conform:[:ch | ch isLetterOrDigit]]) ifFalse:[
+ "/ treat as regular comment
+ commentType := #regularComment.
+ source position:startPos.
+ ] ifTrue:[
+ "/ delimiter comment
+ hereChar == Character cr ifTrue:[
+ hereChar := source nextPeek.
+ ].
+ commentStream notNil ifTrue:[
+ commentStream nextPutLine:delimiter
+ ].
+ stillInComment := true.
+ [stillInComment and:[hereChar notNil]] whileTrue:[
+ line := String streamContents:[:s | self skipToEndOfLineRememberingIn:s].
+ commentStream notNil ifTrue:[
+ commentStream nextPutLine:line
+ ].
+ hereChar == Character cr ifTrue:[
+ hereChar := source nextPeek.
+ ].
+ stillInComment := (line startsWith:delimiter) not.
+ ].
+ stillInComment ifTrue:[
+ self markCommentFrom:startPos to:(source collectionSize).
+ self warning:'unclosed comment (missing delimiter: "',delimiter,'")' position:startPos to:(source position + 1)
+ ].
+ self markCommentFrom:startPos to:(source position + 1).
+ commentType := #delimiterComment.
+ ]
+ ] ifFalse:[
+ commentStream notNil ifTrue:[
+ commentStream nextPut:$<
+ ].
+ ].
+ ].
+
+ (commentType == #regularComment) ifTrue:[
+ hereChar == ${ ifTrue:[
+ "
+ special ST/X addition:
+ a ${ right after the initial double quote starts a directive
+ "
+ self parseDirective
+ ].
+
+ stillInComment := true.
+ [stillInComment] whileTrue:[
+ stillInComment := false.
+
+ [hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[
+ hereChar isSeparator ifFalse:[ anyNonBlank := true ].
+ hereChar == (Character cr) ifTrue:[
+ lineNr := lineNr + 1.
+ ].
+ commentStream notNil ifTrue:[
+ commentStream nextPut:hereChar
+ ].
+ outStream notNil ifTrue:[
+ outStream nextPut:hereChar.
+ outCol := outCol + 1
+ ].
+ hereChar := source nextPeek
+ ].
+
+ hereChar isNil ifTrue:[
+ self markCommentFrom:startPos to:(source collectionSize).
+ self warning:'unclosed comment' position:startPos to:(source position + 1)
+ ] ifFalse:[
+ self markCommentFrom:startPos to:(source position + 1).
+ outStream notNil ifTrue:[
+ outStream nextPut:(Character doubleQuote).
+ outCol := outCol + 1
+ ].
+ ].
+ endPos := source position.
+ "skip final dQuote"
+ source next.
+
+ (source peek == Character doubleQuote) ifTrue:[
+ stillInComment := true.
+ hereChar := source nextPeek.
+ ].
+ ].
+ ]
].
saveComments ifTrue:[
- commentText := commentStream contents.
- self endComment:commentText type:commentType start:startPos end:endPos.
+ commentText := commentStream contents.
+ self endComment:commentText type:commentType start:startPos end:endPos.
].
ignoreWarnings ifFalse:[
- parserFlags warnAboutBadComments ifTrue:[
- anyNonBlank ifFalse:[
- commentType == #regularComment ifTrue:[
- self isDoIt ifFalse:[
- self
- warning:'empty comment'
- doNotShowAgainAction:[ ParserFlags warnAboutBadComments: false ]
- position:startPos to:endPos+1.
- parserFlags warnAboutBadComments:false.
- ]
- ].
- ].
- ].
+ parserFlags warnAboutBadComments ifTrue:[
+ anyNonBlank ifFalse:[
+ commentType == #regularComment ifTrue:[
+ self isDoIt ifFalse:[
+ self
+ warning:'empty comment'
+ doNotShowAgainAction:[ ParserFlags warnAboutBadComments: false ]
+ position:startPos to:endPos+1.
+ parserFlags warnAboutBadComments:false.
+ ]
+ ].
+ ].
+ ].
].
- "Modified: / 30-07-2013 / 20:56:33 / cg"
- "Modified (comment): / 28-07-2017 / 10:34:17 / cg"
+ "Modified: / 30-08-2017 / 09:58:02 / cg"
!
skipToEndOfLineRememberingIn:commentStreamOrNil