Implement non-decreasing do indentation in the alternative layout rule
authorIan Lynagh <igloo@earth.li>
Fri, 27 Nov 2009 01:19:32 +0000 (01:19 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 27 Nov 2009 01:19:32 +0000 (01:19 +0000)
compiler/parser/Lexer.x

index de0ccb6..e131e96 100644 (file)
@@ -1991,7 +1991,9 @@ alternativeLayoutRuleToken t
                     setNextToken t
                     lexTokenAlr
              (_, ALRLayout _ col : ls, Just expectingOCurly)
-              | thisCol > col ->
+              | (thisCol > col) ||
+                (thisCol == col &&
+                 isNonDecreasingIntentation expectingOCurly) ->
                  do setAlrExpectingOCurly Nothing
                     setALRContext (ALRLayout expectingOCurly thisCol : context)
                     setNextToken t
@@ -2089,6 +2091,10 @@ isALRclose ITccurly = True
 isALRclose ITcubxparen = True
 isALRclose _        = False
 
+isNonDecreasingIntentation :: ALRLayout -> Bool
+isNonDecreasingIntentation ALRLayoutDo = True
+isNonDecreasingIntentation _           = False
+
 containsCommas :: Token -> Bool
 containsCommas IToparen = True
 containsCommas ITobrack = True