@@ -332,9 +332,20 @@ totoks pos t =
332332 in Tok pos (CtrlSeq ws) ("\\" <> ws <> ss)
333333 : totoks (incSourceColumn pos
334334 (1 + T.length ws + T.length ss)) rest'''
335− | d == '\t' || d == '\n' ->
336− Tok pos Symbol "\\"
337− : totoks (incSourceColumn pos 1) rest
335+ | isSpaceOrTab d || d == '\n' ->
336+ let (w1, r1) = T.span isSpaceOrTab rest
337+ (w2, (w3, r3)) = case T.uncons r1 of
338+ Just ('\n', r2)
339+ -> (T.pack "\n",
340+ T.span isSpaceOrTab r2)
341+ _ -> (mempty, (w1, r1))
342+ in case T.uncons r3 of
343+ Just ('\n', _) ->
344+ Tok pos (CtrlSeq " ") ("\\" <> w1)
345+ : totoks (incSourceColumn pos 1) r1
346+ _ ->
347+ Tok pos (CtrlSeq " ") ("\\" <> w1 <> w2 <> w3)
348+ : totoks (incSourceColumn pos 1) r3
338349 | otherwise ->
339350 Tok pos (CtrlSeq (T.singleton d)) (T.pack [c,d])
340351 : totoks (incSourceColumn pos 2) rest'