X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fparser%2FLexer.x;h=00926bd13d87b6a7c0f6db94e008a3c42223bd58;hp=85d4d12dca714cbb6cf4d5780381cdf7a5e19834;hb=609e7ddfb10bc04762b820e70e0487ad6c514c2e;hpb=16c7844d29b7b90e6cf432ec646f70d466ca9cc9 diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 85d4d12..00926bd 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -31,15 +31,15 @@ -- qualified varids. { -{-# OPTIONS -Wwarn -w #-} --- The above -Wwarn supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings --- for details --- --- Note that Alex itself generates code with with some unused bindings and --- without type signatures, so removing the flag might not be possible. +-- XXX The above flags turn off warnings in the generated code: +{-# OPTIONS_GHC -fno-warn-unused-matches #-} +{-# OPTIONS_GHC -fno-warn-unused-binds #-} +{-# OPTIONS_GHC -fno-warn-unused-imports #-} +{-# OPTIONS_GHC -fno-warn-missing-signatures #-} +-- But alex still generates some code that causes the "lazy unlifted bindings" +-- warning, and old compilers don't know about it so we can't easily turn +-- it off, so for now we use the sledge hammer: +{-# OPTIONS_GHC -w #-} {-# OPTIONS_GHC -funbox-strict-fields #-} @@ -1998,6 +1998,15 @@ alternativeLayoutRuleToken t 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] @@ -2014,7 +2023,8 @@ alternativeLayoutRuleToken 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" @@ -2055,13 +2065,6 @@ alternativeLayoutRuleToken t 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 @@ -2070,6 +2073,8 @@ isALRopen ITif = True isALRopen IToparen = True isALRopen ITobrack = True isALRopen ITocurly = True +-- GHC Extensions: +isALRopen IToubxparen = True isALRopen _ = False isALRclose :: Token -> Bool @@ -2078,11 +2083,15 @@ isALRclose ITthen = True 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