setALRContext (ALRLayout expectingOCurly thisCol : context)
setNextToken t
return (L thisLoc ITocurly)
+ -- We do the [] cases earlier than in the spec, as we
+ -- have an actual EOF token
+ (ITeof, ALRLayout _ _ : ls, _) ->
+ do setALRContext ls
+ setNextToken t
+ return (L thisLoc ITccurly)
+ (ITeof, _, _) ->
+ return t
+ -- the other ITeof case omitted; general case below covers it
(ITin, ALRLayout ALRLayoutLet _ : ls, _)
| newLine ->
do setPendingImplicitTokens [t]
f ls' = ([], ls')
case f ls of
(t' : ts, ls') ->
- do setPendingImplicitTokens ts
+ do setALRContext ls'
+ setPendingImplicitTokens ts
setNextToken t
return t'
_ -> panic "Layout rule: [] when considering newline"
setPendingImplicitTokens [t]
return (L thisLoc ITccurly)
-- the other ITwhere case omitted; general case below covers it
- -- The first [] case comes before the general case, as we
- -- have an actual EOF token
- (ITeof, ALRLayout _ _ : ls, _) ->
- do setALRContext ls
- setNextToken t
- return (L thisLoc ITccurly)
- -- the other ITeof case omitted; general case below covers it
(_, _, _) -> return t
isALRopen :: Token -> Bool
isALRopen IToparen = True
isALRopen ITobrack = True
isALRopen ITocurly = True
+-- GHC Extensions:
+isALRopen IToubxparen = True
isALRopen _ = False
isALRclose :: Token -> Bool
isALRclose ITcparen = True
isALRclose ITcbrack = True
isALRclose ITccurly = True
+-- GHC Extensions:
+isALRclose ITcubxparen = True
isALRclose _ = False
containsCommas :: Token -> Bool
containsCommas IToparen = True
containsCommas ITobrack = True
+-- GHC Extensions:
+containsCommas IToubxparen = True
containsCommas _ = False
topNoLayoutContainsCommas :: [ALRContext] -> Bool