ghc-parser 0.1.8.0 → 0.2.0.0
raw patch · 7 files changed
+692/−94 lines, 7 filesdep ~basedep ~ghcsetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, ghc
API changes (from Hackage documentation)
Files
- Setup.hs +6/−7
- generic-src/Language/Haskell/GHC/Parser.hs +43/−2
- ghc-parser.cabal +7/−4
- src-7.6/Language/Haskell/GHC/HappyParser.hs +198/−27
- src-7.8.2/Language/Haskell/GHC/HappyParser.hs +198/−27
- src-7.8.3/Language/Haskell/GHC/HappyParser.hs +198/−27
- src-8.0/Language/Haskell/GHC/HappyParser.hs +42/−0
Setup.hs view
@@ -1,8 +1,7 @@-import Distribution.Simple-import System.Cmd+import Distribution.Simple+import System.Process -main = defaultMainWithHooks simpleUserHooks{- preConf = \args confFlags -> do- system "./build-parser.sh"- preConf simpleUserHooks args confFlags-}+main = defaultMainWithHooks+ simpleUserHooks { preConf = \args confFlags -> do+ system "./build-parser.sh"+ preConf simpleUserHooks args confFlags }
generic-src/Language/Haskell/GHC/Parser.hs view
@@ -23,7 +23,8 @@ layoutChunks, ) where -import Data.List (intercalate, findIndex)+import Data.List (intercalate, findIndex, isInfixOf)+import Data.Char (isAlphaNum) import Bag import ErrUtils hiding (ErrMsg)@@ -131,8 +132,10 @@ -- A chunk is a line and all lines immediately following that are indented -- beyond the indentation of the first line. This parses Haskell layout -- rules properly, and allows using multiline expressions via indentation.+--+-- Quasiquotes are allowed via a post-processing step. layoutChunks :: String -> [Located String]-layoutChunks = go 1+layoutChunks = joinQuasiquotes . go 1 where go :: LineNumber -> String -> [Located String] go line = filter (not . null . unloc) . map (fmap strip) . layoutLines line . lines@@ -174,6 +177,7 @@ indentLevel _ = 0 + -- | Drop comments from Haskell source. -- Simply gets rid of them, does not replace them in any way. removeComments :: String -> String@@ -240,3 +244,40 @@ '"':rest -> "\"" x:xs -> x:takeString xs [] -> []+++-- | Post processing step to combine quasiquoted blocks into single blocks.+-- This is necessary because quasiquoted blocks don't follow normal indentation rules.+joinQuasiquotes :: [Located String] -> [Located String]+joinQuasiquotes = reverse . joinQuasiquotes' . reverse+ where+ -- This operates by finding |] and then joining blocks until a line+ -- that has some corresponding [...|. This is still a hack, but close to+ -- good enough.+ joinQuasiquotes' [] = []+ joinQuasiquotes' (block:blocks) =+ if "|]" `isInfixOf` unloc block+ then+ let (pieces, rest) = break (hasQuasiquoteStart . unloc) blocks+ in case rest of+ [] -> block : joinQuasiquotes' blocks+ startBlock:blocks' ->+ concatBlocks (block : pieces ++ [startBlock]) : joinQuasiquotes blocks'+ else block : joinQuasiquotes' blocks++ -- Combine a lit of reversed blocks into a single, non-reversed block.+ concatBlocks :: [Located String] -> Located String+ concatBlocks blocks = Located (line $ last blocks) $ joinLines $ map unloc $ reverse blocks++ -- Does this string have a [...| in it?+ hasQuasiquoteStart :: String -> Bool+ hasQuasiquoteStart str =+ case break (== '[') str of+ (_, "") -> False+ (_, _:rest) ->+ case break (== '|') rest of+ (_, "") -> False+ (chars, _) -> all isIdentChar chars++ isIdentChar :: Char -> Bool+ isIdentChar c = isAlphaNum c || c == '_' || c == '\''
ghc-parser.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: ghc-parser-version: 0.1.8.0+version: 0.2.0.0 synopsis: Haskell source parser from GHC. -- description: homepage: https://github.com/gibiansky/IHaskell@@ -33,8 +33,8 @@ Language.Haskell.GHC.HappyParser -- other-modules: -- other-extensions:- build-depends: base >=4.6 && <4.9,- ghc >=7.6 && <7.11+ build-depends: base >=4.6 && < 5,+ ghc >=7.6 && <8.1 if impl(ghc >= 7.6) && impl(ghc < 7.8) hs-source-dirs: generic-src src-7.6@@ -45,6 +45,9 @@ if impl(ghc < 7.10) hs-source-dirs: generic-src src-7.8.3 else- hs-source-dirs: generic-src src-7.10+ if impl(ghc < 8.0)+ hs-source-dirs: generic-src src-7.10+ else+ hs-source-dirs: generic-src src-8.0 default-language: Haskell2010
src-7.6/Language/Haskell/GHC/HappyParser.hs view
@@ -26667,9 +26667,11 @@ {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "<built-in>" #-}-{-# LINE 16 "<built-in>" #-}-{-# LINE 1 "/Users/silver/.stack/programs/x86_64-osx/ghc-7.10.2/lib/ghc-7.10.2/include/ghcversion.h" #-}+{-# LINE 1 "<command-line>" #-}+{-# LINE 8 "<command-line>" #-}+# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 17 "/usr/include/stdc-predef.h" 3 4 @@ -26687,15 +26689,10 @@ -{-# LINE 17 "<built-in>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp -{-# LINE 13 "templates/GenericTemplate.hs" #-} -{-# LINE 46 "templates/GenericTemplate.hs" #-} @@ -26705,10 +26702,8 @@ -{-# LINE 67 "templates/GenericTemplate.hs" #-} -{-# LINE 77 "templates/GenericTemplate.hs" #-} @@ -26719,6 +26714,198 @@ +{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "/home/andrei/.stack/programs/x86_64-linux/ghc-8.0.2/lib/ghc-8.0.2/include/ghcversion.h" #-}++++++++++++++++++{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "/tmp/ghc2743_0/ghc_2.h" #-}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "templates/GenericTemplate.hs" #-}+-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp ++{-# LINE 13 "templates/GenericTemplate.hs" #-}++{-# LINE 46 "templates/GenericTemplate.hs" #-}+++++++++{-# LINE 67 "templates/GenericTemplate.hs" #-}++{-# LINE 77 "templates/GenericTemplate.hs" #-}++{-# LINE 86 "templates/GenericTemplate.hs" #-}+ infixr 9 `HappyStk` data HappyStk a = HappyStk a (HappyStk a) @@ -26741,7 +26928,6 @@ ----------------------------------------------------------------------------- -- Arrays only: do the next action - {-# LINE 155 "templates/GenericTemplate.hs" #-} -----------------------------------------------------------------------------@@ -26836,14 +27022,7 @@ ----------------------------------------------------------------------------- -- Moving to a new state after a reduction --------+{-# LINE 256 "templates/GenericTemplate.hs" #-} happyGoto action j tk st = action j j tk (HappyState action) @@ -26902,14 +27081,7 @@ -- of deciding to inline happyGoto everywhere, which increases the size of -- the generated parser quite a bit. --------+{-# LINE 322 "templates/GenericTemplate.hs" #-} {-# NOINLINE happyShift #-} {-# NOINLINE happySpecReduce_0 #-} {-# NOINLINE happySpecReduce_1 #-}@@ -26921,4 +27093,3 @@ {-# NOINLINE happyFail #-} -- end of Happy Template.-
src-7.8.2/Language/Haskell/GHC/HappyParser.hs view
@@ -29391,9 +29391,11 @@ {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "<built-in>" #-}-{-# LINE 16 "<built-in>" #-}-{-# LINE 1 "/Users/silver/.stack/programs/x86_64-osx/ghc-7.10.2/lib/ghc-7.10.2/include/ghcversion.h" #-}+{-# LINE 1 "<command-line>" #-}+{-# LINE 8 "<command-line>" #-}+# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 17 "/usr/include/stdc-predef.h" 3 4 @@ -29411,15 +29413,10 @@ -{-# LINE 17 "<built-in>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp -{-# LINE 13 "templates/GenericTemplate.hs" #-} -{-# LINE 46 "templates/GenericTemplate.hs" #-} @@ -29429,10 +29426,8 @@ -{-# LINE 67 "templates/GenericTemplate.hs" #-} -{-# LINE 77 "templates/GenericTemplate.hs" #-} @@ -29443,6 +29438,198 @@ +{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "/home/andrei/.stack/programs/x86_64-linux/ghc-8.0.2/lib/ghc-8.0.2/include/ghcversion.h" #-}++++++++++++++++++{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "/tmp/ghc2743_0/ghc_2.h" #-}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "templates/GenericTemplate.hs" #-}+-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp ++{-# LINE 13 "templates/GenericTemplate.hs" #-}++{-# LINE 46 "templates/GenericTemplate.hs" #-}+++++++++{-# LINE 67 "templates/GenericTemplate.hs" #-}++{-# LINE 77 "templates/GenericTemplate.hs" #-}++{-# LINE 86 "templates/GenericTemplate.hs" #-}+ infixr 9 `HappyStk` data HappyStk a = HappyStk a (HappyStk a) @@ -29465,7 +29652,6 @@ ----------------------------------------------------------------------------- -- Arrays only: do the next action - {-# LINE 155 "templates/GenericTemplate.hs" #-} -----------------------------------------------------------------------------@@ -29560,14 +29746,7 @@ ----------------------------------------------------------------------------- -- Moving to a new state after a reduction --------+{-# LINE 256 "templates/GenericTemplate.hs" #-} happyGoto action j tk st = action j j tk (HappyState action) @@ -29626,14 +29805,7 @@ -- of deciding to inline happyGoto everywhere, which increases the size of -- the generated parser quite a bit. --------+{-# LINE 322 "templates/GenericTemplate.hs" #-} {-# NOINLINE happyShift #-} {-# NOINLINE happySpecReduce_0 #-} {-# NOINLINE happySpecReduce_1 #-}@@ -29645,4 +29817,3 @@ {-# NOINLINE happyFail #-} -- end of Happy Template.-
src-7.8.3/Language/Haskell/GHC/HappyParser.hs view
@@ -29391,9 +29391,11 @@ {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "<built-in>" #-}-{-# LINE 16 "<built-in>" #-}-{-# LINE 1 "/Users/silver/.stack/programs/x86_64-osx/ghc-7.10.2/lib/ghc-7.10.2/include/ghcversion.h" #-}+{-# LINE 1 "<command-line>" #-}+{-# LINE 8 "<command-line>" #-}+# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 17 "/usr/include/stdc-predef.h" 3 4 @@ -29411,15 +29413,10 @@ -{-# LINE 17 "<built-in>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp -{-# LINE 13 "templates/GenericTemplate.hs" #-} -{-# LINE 46 "templates/GenericTemplate.hs" #-} @@ -29429,10 +29426,8 @@ -{-# LINE 67 "templates/GenericTemplate.hs" #-} -{-# LINE 77 "templates/GenericTemplate.hs" #-} @@ -29443,6 +29438,198 @@ +{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "/home/andrei/.stack/programs/x86_64-linux/ghc-8.0.2/lib/ghc-8.0.2/include/ghcversion.h" #-}++++++++++++++++++{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "/tmp/ghc2743_0/ghc_2.h" #-}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++{-# LINE 8 "<command-line>" #-}+{-# LINE 1 "templates/GenericTemplate.hs" #-}+-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp ++{-# LINE 13 "templates/GenericTemplate.hs" #-}++{-# LINE 46 "templates/GenericTemplate.hs" #-}+++++++++{-# LINE 67 "templates/GenericTemplate.hs" #-}++{-# LINE 77 "templates/GenericTemplate.hs" #-}++{-# LINE 86 "templates/GenericTemplate.hs" #-}+ infixr 9 `HappyStk` data HappyStk a = HappyStk a (HappyStk a) @@ -29465,7 +29652,6 @@ ----------------------------------------------------------------------------- -- Arrays only: do the next action - {-# LINE 155 "templates/GenericTemplate.hs" #-} -----------------------------------------------------------------------------@@ -29560,14 +29746,7 @@ ----------------------------------------------------------------------------- -- Moving to a new state after a reduction --------+{-# LINE 256 "templates/GenericTemplate.hs" #-} happyGoto action j tk st = action j j tk (HappyState action) @@ -29626,14 +29805,7 @@ -- of deciding to inline happyGoto everywhere, which increases the size of -- the generated parser quite a bit. --------+{-# LINE 322 "templates/GenericTemplate.hs" #-} {-# NOINLINE happyShift #-} {-# NOINLINE happySpecReduce_0 #-} {-# NOINLINE happySpecReduce_1 #-}@@ -29645,4 +29817,3 @@ {-# NOINLINE happyFail #-} -- end of Happy Template.-
+ src-8.0/Language/Haskell/GHC/HappyParser.hs view
@@ -0,0 +1,42 @@+module Language.Haskell.GHC.HappyParser+ ( fullStatement+ , fullImport+ , fullDeclaration+ , fullExpression+ , fullTypeSignature+ , fullModule+ ) where++import Parser+import SrcLoc++-- compiler/hsSyn+import HsSyn++-- compiler/utils+import OrdList++-- compiler/parser+import RdrHsSyn+import Lexer++-- compiler/basicTypes+import RdrName++fullStatement :: P (Maybe (LStmt RdrName (LHsExpr RdrName)))+fullStatement = parseStmt++fullImport :: P (LImportDecl RdrName)+fullImport = parseImport++fullDeclaration :: P (OrdList (LHsDecl RdrName))+fullDeclaration = fmap unitOL parseDeclaration++fullExpression :: P (LHsExpr RdrName)+fullExpression = parseExpression++fullTypeSignature :: P (Located (OrdList (LHsDecl RdrName)))+fullTypeSignature = fmap (noLoc . unitOL) parseTypeSignature++fullModule :: P (Located (HsModule RdrName))+fullModule = parseModule