@@ -54,6 +54,9 @@ object Scanners {
5454 /** the base of a number */
5555 var base : Int = 0
5656
57+ /** Set to false to disable end marker alignment checks, used for outline parsing. */
58+ var checkEndMarker : Boolean = true
59+
5760 def copyFrom (td : TokenData ): Unit = {
5861 this .token = td.token
5962 this .offset = td.offset
@@ -331,10 +334,12 @@ object Scanners {
331334 def endMarkerScope [T ](tag : EndMarkerTag )(op : => T ): T =
332335 val saved = openEndMarkers
333336 openEndMarkers = (tag, currentRegion.indentWidth) :: openEndMarkers
334- try op finally openEndMarkers = saved
337+ try op
338+ finally openEndMarkers = saved
335339
336340 /** If this token and the next constitute an end marker, skip them and check they
337- * align with an opening construct with the same end marker tag.
341+ * align with an opening construct with the same end marker tag,
342+ * unless `checkEndMarker` is false.
338343 */
339344 protected def skipEndMarker (width : IndentWidth ): Unit =
340345 if next.token == IDENTIFIER && next.name == nme.end then
@@ -348,8 +353,9 @@ object Scanners {
348353 openEndMarkers = rest
349354 checkAligned()
350355 case _ =>
351- lexical.println(i " misaligned end marker $tag, $width, $openEndMarkers" )
352- errorButContinue(" misaligned end marker" , start)
356+ if checkEndMarker
357+ lexical.println(i " misaligned end marker $tag, $width, $openEndMarkers" )
358+ errorButContinue(" misaligned end marker" , start)
353359
354360 val skipTo = lookahead.charOffset
355361 lookahead.nextToken()
0 commit comments