From aa9682ccc5521d367d76ae7abba7af03bfee3a68 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 27 Nov 2009 01:19:32 +0000 Subject: [PATCH] Implement non-decreasing do indentation in the alternative layout rule --- compiler/parser/Lexer.x | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index de0ccb6..e131e96 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -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 -- 1.7.10.4