X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fparser%2FLexer.x;h=e52880b64b9d671565a72a634410983fe172260f;hp=eab9419369d527311ffa41a74b236329891bff96;hb=9a82b1ffa35fa4c3927c66a1037a37d436cf6aac;hpb=83d563cb9ede0ba792836e529b1e2929db926355 diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index eab9419..e52880b 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -32,6 +32,7 @@ { -- XXX The above flags turn off warnings in the generated code: +{-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} @@ -308,6 +309,10 @@ $tab+ { warn Opt_WarnTabs (text "Warning: Tab character") } \$ @varid / { ifExtension thEnabled } { skip_one_varid ITidEscape } "$(" / { ifExtension thEnabled } { token ITparenEscape } +-- For backward compatibility, accept the old dollar syntax + "[$" @varid "|" / { ifExtension qqEnabled } + { lex_quasiquote_tok } + "[" @varid "|" / { ifExtension qqEnabled } { lex_quasiquote_tok } } @@ -1102,10 +1107,12 @@ new_layout_context strict span _buf _len = do (AI l _) <- getInput let offset = srcLocCol l ctx <- getContext + relaxed <- extension relaxedLayout + let strict' = strict || not relaxed case ctx of Layout prev_off : _ | - (strict && prev_off >= offset || - not strict && prev_off > offset) -> do + (strict' && prev_off >= offset || + not strict' && prev_off > offset) -> do -- token is indented to the left of the previous context. -- we must generate a {} sequence now. pushLexState layout_left @@ -1756,6 +1763,8 @@ recBit :: Int recBit = 22 -- rec alternativeLayoutRuleBit :: Int alternativeLayoutRuleBit = 23 +relaxedLayoutBit :: Int +relaxedLayoutBit = 24 always :: Int -> Bool always _ = True @@ -1799,6 +1808,8 @@ oldQualOps :: Int -> Bool oldQualOps flags = not (newQualOps flags) alternativeLayoutRule :: Int -> Bool alternativeLayoutRule flags = testBit flags alternativeLayoutRuleBit +relaxedLayout :: Int -> Bool +relaxedLayout flags = testBit flags relaxedLayoutBit -- PState for parsing options pragmas -- @@ -1852,6 +1863,7 @@ mkPState flags buf loc = .|. rawTokenStreamBit `setBitIf` dopt Opt_KeepRawTokenStream flags .|. newQualOpsBit `setBitIf` xopt Opt_NewQualifiedOperators flags .|. alternativeLayoutRuleBit `setBitIf` xopt Opt_AlternativeLayoutRule flags + .|. relaxedLayoutBit `setBitIf` xopt Opt_RelaxedLayout flags -- setBitIf :: Int -> Bool -> Int b `setBitIf` cond | cond = bit b