3240 |
3247 |
3241 self skipToEndOfLineRememberingIn:commentStream. |
3248 self skipToEndOfLineRememberingIn:commentStream. |
3242 endPos := source position1Based. |
3249 endPos := source position1Based. |
3243 self markCommentFrom:startPos to:endPos. |
3250 self markCommentFrom:startPos to:endPos. |
3244 commentType := #eolComment. |
3251 commentType := #eolComment. |
3245 lineNr := lineNr + 1. |
|
3246 self warnSTXSpecialCommentAt:startPos to:endPos-1. |
3252 self warnSTXSpecialCommentAt:startPos to:endPos-1. |
3247 outStream notNil ifTrue:[ |
3253 outStream notNil ifTrue:[ |
3248 outStream cr. |
3254 outStream cr. |
3249 outCol := 1 |
3255 outCol := 1 |
3250 ]. |
3256 ]. |
3251 "skip cr" |
3257 "skip cr" |
3252 source next. |
3258 source next. |
3253 ] ifFalse:[ |
3259 ] ifFalse:[ |
3254 commentType := #regularComment. |
3260 (hereChar == $< and:[parserFlags allowSTXDelimiterComments]) ifTrue:[ |
3255 |
3261 hereChar := source nextPeek. |
3256 hereChar == ${ ifTrue:[ |
3262 (hereChar == $<) ifTrue:[ |
3257 " |
3263 "everything up to EOL is the delimiter; comment extends to everything up |
3258 special ST/X addition: |
3264 to a line consisting of the delimiter alone" |
3259 a ${ right after the initial double quote starts a directive |
3265 commentStream notNil ifTrue:[ |
3260 " |
3266 commentStream nextPutAll:'>>' |
3261 self parseDirective |
|
3262 ]. |
|
3263 |
|
3264 stillInComment := true. |
|
3265 [stillInComment] whileTrue:[ |
|
3266 stillInComment := false. |
|
3267 |
|
3268 [hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[ |
|
3269 hereChar isSeparator ifFalse:[ |
|
3270 anyNonBlank := true. |
|
3271 ]. |
3267 ]. |
3272 hereChar == (Character cr) ifTrue:[ |
3268 hereChar := source nextPeek. |
3273 lineNr := lineNr + 1. |
3269 delimiter := String streamContents:[:s | self skipToEndOfLineRememberingIn:s]. |
|
3270 delimiter withoutSeparators isEmpty ifTrue:[ |
|
3271 self parseError:'invalid delimiter in comment' |
|
3272 ]. |
|
3273 hereChar == Character cr ifTrue:[ |
|
3274 hereChar := source nextPeek. |
3274 ]. |
3275 ]. |
3275 commentStream notNil ifTrue:[ |
3276 commentStream notNil ifTrue:[ |
3276 commentStream nextPut:hereChar |
3277 commentStream nextPutLine:delimiter |
3277 ]. |
3278 ]. |
3278 outStream notNil ifTrue:[ |
3279 stillInComment := true. |
3279 outStream nextPut:hereChar. |
3280 [stillInComment] whileTrue:[ |
3280 outCol := outCol + 1 |
3281 line := String streamContents:[:s | self skipToEndOfLineRememberingIn:s]. |
|
3282 commentStream notNil ifTrue:[ |
|
3283 commentStream nextPutLine:line |
|
3284 ]. |
|
3285 hereChar == Character cr ifTrue:[ |
|
3286 hereChar := source nextPeek. |
|
3287 ]. |
|
3288 stillInComment := (line ~= delimiter). |
3281 ]. |
3289 ]. |
3282 hereChar := source nextPeek |
3290 commentType := #delimiterComment. |
3283 ]. |
|
3284 |
|
3285 hereChar isNil ifTrue:[ |
|
3286 self markCommentFrom:startPos to:(source size). |
|
3287 self warning:'unclosed comment' position:startPos to:(source position1Based) |
|
3288 ] ifFalse:[ |
3291 ] ifFalse:[ |
3289 self markCommentFrom:startPos to:(source position1Based). |
3292 commentStream notNil ifTrue:[ |
3290 outStream notNil ifTrue:[ |
3293 commentStream nextPut:$> |
3291 outStream nextPut:(Character doubleQuote). |
|
3292 outCol := outCol + 1 |
|
3293 ]. |
3294 ]. |
3294 ]. |
3295 ]. |
3295 endPos := source position1Based. |
3296 ]. |
3296 "skip final dQuote" |
3297 |
3297 source next. |
3298 (commentType == #regularComment) ifTrue:[ |
3298 |
3299 hereChar == ${ ifTrue:[ |
3299 (source peek == Character doubleQuote) ifTrue:[ |
3300 " |
3300 stillInComment := true. |
3301 special ST/X addition: |
3301 hereChar := source nextPeek. |
3302 a ${ right after the initial double quote starts a directive |
3302 ]. |
3303 " |
3303 ]. |
3304 self parseDirective |
|
3305 ]. |
|
3306 |
|
3307 stillInComment := true. |
|
3308 [stillInComment] whileTrue:[ |
|
3309 stillInComment := false. |
|
3310 |
|
3311 [hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[ |
|
3312 hereChar isSeparator ifFalse:[ |
|
3313 anyNonBlank := true. |
|
3314 ]. |
|
3315 hereChar == (Character cr) ifTrue:[ |
|
3316 lineNr := lineNr + 1. |
|
3317 ]. |
|
3318 commentStream notNil ifTrue:[ |
|
3319 commentStream nextPut:hereChar |
|
3320 ]. |
|
3321 outStream notNil ifTrue:[ |
|
3322 outStream nextPut:hereChar. |
|
3323 outCol := outCol + 1 |
|
3324 ]. |
|
3325 hereChar := source nextPeek |
|
3326 ]. |
|
3327 |
|
3328 hereChar isNil ifTrue:[ |
|
3329 self markCommentFrom:startPos to:(source size). |
|
3330 self warning:'unclosed comment' position:startPos to:(source position1Based) |
|
3331 ] ifFalse:[ |
|
3332 self markCommentFrom:startPos to:(source position1Based). |
|
3333 outStream notNil ifTrue:[ |
|
3334 outStream nextPut:(Character doubleQuote). |
|
3335 outCol := outCol + 1 |
|
3336 ]. |
|
3337 ]. |
|
3338 endPos := source position1Based. |
|
3339 "skip final dQuote" |
|
3340 source next. |
|
3341 |
|
3342 (source peek == Character doubleQuote) ifTrue:[ |
|
3343 stillInComment := true. |
|
3344 hereChar := source nextPeek. |
|
3345 ]. |
|
3346 ]. |
|
3347 ] |
3304 ]. |
3348 ]. |
3305 |
3349 |
3306 saveComments ifTrue:[ |
3350 saveComments ifTrue:[ |
3307 commentText := commentStream contents. |
3351 commentText := commentStream contents. |
3308 self endComment:commentText type:commentType. |
3352 self endComment:commentText type:commentType. |