X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fparser%2FLexer.x;h=1bb8a636e40c39d531a14d8b84249f61f3265874;hp=00926bd13d87b6a7c0f6db94e008a3c42223bd58;hb=9568347eb0ae5d11354e0e4744c0f6af8b65b0be;hpb=609e7ddfb10bc04762b820e70e0487ad6c514c2e diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 00926bd..1bb8a63 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -2012,22 +2012,15 @@ alternativeLayoutRuleToken t do setPendingImplicitTokens [t] setALRContext ls return (L thisLoc ITccurly) - (_, ls@(ALRLayout _ col : _), _) - | newLine && thisCol <= col -> - do let f ls'@(ALRLayout _ col' : ls'') - | thisCol < col' = case f ls'' of - (ts, ls''') -> - (L thisLoc ITccurly : ts, ls''') - | thisCol == col' = ([L thisLoc ITsemi], ls') - | otherwise = ([], ls') - f ls' = ([], ls') - case f ls of - (t' : ts, ls') -> - do setALRContext ls' - setPendingImplicitTokens ts - setNextToken t - return t' - _ -> panic "Layout rule: [] when considering newline" + (_, ALRLayout _ col : ls, _) + | newLine && thisCol == col -> + do setNextToken t + return (L thisLoc ITsemi) + | newLine && thisCol < col -> + do setALRContext ls + -- Note that we use lastLoc, as we may need to close + -- more layouts, or give a semicolon + return (L lastLoc ITccurly) (u, _, _) | isALRopen u -> do setALRContext (ALRNoLayout (containsCommas u) : context) @@ -2050,7 +2043,7 @@ alternativeLayoutRuleToken t do setALRContext ls setPendingImplicitTokens [t] return (L thisLoc ITccurly) - (ITin, _ : ls, _) -> + (ITin, ALRLayout _ _ : ls, _) -> do setALRContext ls setNextToken t return (L thisLoc ITccurly)