X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fparser%2FLexer.x;h=90fbf7a8c23cd5aab750aa0fa1f99d66a5e57fa9;hb=5d3051c66796dcf884b052f9e4afc3ed19b9f514;hp=be8dadd1c19ade6e3711cc9cf6847558ea70f47d;hpb=61b0395995feafffe2073dcbcac5f1fb1e73ee85;p=ghc-hetmet.git diff --git a/ghc/compiler/parser/Lexer.x b/ghc/compiler/parser/Lexer.x index be8dadd..90fbf7a 100644 --- a/ghc/compiler/parser/Lexer.x +++ b/ghc/compiler/parser/Lexer.x @@ -26,7 +26,8 @@ module Lexer ( P(..), ParseResult(..), getSrcLoc, failLocMsgP, failSpanMsgP, srcParseFail, popContext, pushCurrentContext, setLastToken, setSrcLoc, - getLexState, popLexState, pushLexState + getLexState, popLexState, pushLexState, + extension, bangPatEnabled ) where #include "HsVersions.h" @@ -559,10 +560,13 @@ reservedSymsFM = listToUFM $ ,(">>-", ITRarrowtail, bit arrowsBit) #if __GLASGOW_HASKELL__ >= 605 - ,("∀", ITforall, bit tvBit) - ,("→", ITrarrow, 0) - ,("←", ITlarrow, 0) - ,("⋯", ITdotdot, 0) + ,("λ", ITlam, bit glaExtsBit) + ,("∷", ITdcolon, bit glaExtsBit) + ,("⇒", ITdarrow, bit glaExtsBit) + ,("∀", ITforall, bit glaExtsBit) + ,("→", ITrarrow, bit glaExtsBit) + ,("←", ITlarrow, bit glaExtsBit) + ,("⋯", ITdotdot, bit glaExtsBit) #endif ] @@ -1254,6 +1258,8 @@ arrowsBit = 4 thBit = 5 ipBit = 6 tvBit = 7 -- Scoped type variables enables 'forall' keyword +bangPatBit = 8 -- Tells the parser to understand bang-patterns + -- (doesn't affect the lexer) glaExtsEnabled, ffiEnabled, parrEnabled :: Int -> Bool glaExtsEnabled flags = testBit flags glaExtsBit @@ -1263,6 +1269,7 @@ arrowsEnabled flags = testBit flags arrowsBit thEnabled flags = testBit flags thBit ipEnabled flags = testBit flags ipBit tvEnabled flags = testBit flags tvBit +bangPatEnabled flags = testBit flags bangPatBit -- create a parse state -- @@ -1287,6 +1294,7 @@ mkPState buf loc flags = .|. thBit `setBitIf` dopt Opt_TH flags .|. ipBit `setBitIf` dopt Opt_ImplicitParams flags .|. tvBit `setBitIf` dopt Opt_ScopedTypeVariables flags + .|. bangPatBit `setBitIf` dopt Opt_BangPatterns flags -- setBitIf :: Int -> Bool -> Int b `setBitIf` cond | cond = bit b @@ -1381,6 +1389,10 @@ lexToken = do span `seq` setLastToken span bytes t span buf bytes +-- ToDo: Alex reports the buffer at the start of the erroneous lexeme, +-- but it would be more informative to report the location where the +-- error was actually discovered, especially if this is a decoding +-- error. reportLexError loc1 loc2 buf str = let c = fst (nextChar buf)