Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
5da837a7
Commit
5da837a7
authored
Oct 09, 2021
by
Vaibhav Sagar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ghc-parser: support GHC 9.2
parent
c2798505
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
3 deletions
+66
-3
Parser.hs
ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs
+21
-1
ghc-parser.cabal
ghc-parser/ghc-parser.cabal
+5
-2
HappyParser.hs
ghc-parser/src-9.2/Language/Haskell/GHC/HappyParser.hs
+40
-0
No files found.
ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs
View file @
5da837a7
...
...
@@ -28,6 +28,11 @@ module Language.Haskell.GHC.Parser (
import
Data.List
(
intercalate
,
findIndex
,
isInfixOf
)
import
Data.Char
(
isAlphaNum
)
#
if
MIN_VERSION_ghc
(
9
,
2
,
0
)
import
GHC.Driver.Config
(
initParserOpts
)
import
GHC.Parser.Errors.Ppr
(
pprError
)
#
endif
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
GHC.Data.Bag
import
GHC.Driver.Session
(
parseDynamicFilePragma
)
...
...
@@ -144,12 +149,23 @@ runParser flags (Parser parser) str =
let
filename
=
"<interactive>"
location
=
SrcLoc
.
mkRealSrcLoc
(
mkFastString
filename
)
1
1
buffer
=
stringToStringBuffer
str
#
if
MIN_VERSION_ghc
(
9
,
2
,
0
)
parseState
=
initParserState
(
initParserOpts
flags
)
buffer
location
in
#
else
parseState
=
mkPState
flags
buffer
location
in
#
endif
-- Convert a GHC parser output into our own.
toParseOut
$
unP
parser
parseState
where
toParseOut
::
ParseResult
a
->
ParseOutput
a
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
2
,
0
)
toParseOut
(
PFailed
pstate
)
=
let
realSpan
=
SrcLoc
.
psRealSpan
$
last_loc
pstate
errMsg
=
printErrorBag
(
errors
pstate
)
ln
=
srcLocLine
$
SrcLoc
.
realSrcSpanStart
realSpan
col
=
srcLocCol
$
SrcLoc
.
realSrcSpanStart
realSpan
in
Failure
errMsg
$
Loc
ln
col
#
elif
MIN_VERSION_ghc
(
9
,
0
,
0
)
toParseOut
(
PFailed
pstate
)
=
let
realSpan
=
SrcLoc
.
psRealSpan
$
last_loc
pstate
errMsg
=
printErrorBag
$
snd
$
(
messages
pstate
)
flags
...
...
@@ -192,7 +208,11 @@ runParser flags (Parser parser) str =
Parsed
result
-- Convert the bag of errors into an error string.
#
if
MIN_VERSION_ghc
(
9
,
2
,
0
)
printErrorBag
bag
=
joinLines
.
map
(
show
.
pprError
)
$
bagToList
bag
#
else
printErrorBag
bag
=
joinLines
.
map
show
$
bagToList
bag
#
endif
-- Taken from http://blog.shaynefletcher.org/2019/06/have-ghc-parsing-respect-dynamic-pragmas.html
parsePragmasIntoDynFlags
::
DynFlags
->
FilePath
->
String
->
IO
(
Maybe
DynFlags
)
...
...
ghc-parser/ghc-parser.cabal
View file @
5da837a7
...
...
@@ -23,7 +23,7 @@ library
-- other-modules:
-- other-extensions:
build-depends: base >=4.9 && < 5,
ghc >=8.0 && <9.
1
ghc >=8.0 && <9.
3
if impl(ghc >= 8.0) && impl(ghc < 8.4)
hs-source-dirs: generic-src src-8.0
...
...
@@ -34,7 +34,10 @@ library
if impl(ghc >= 8.10) && impl(ghc < 9.0)
hs-source-dirs: generic-src src-8.10
else
hs-source-dirs: generic-src src-9.0
if impl(ghc >= 9.0) && impl(ghc < 9.2)
hs-source-dirs: generic-src src-9.0
else
hs-source-dirs: generic-src src-9.2
default-language: Haskell2010
ghc-parser/src-9.2/Language/Haskell/GHC/HappyParser.hs
0 → 100644
View file @
5da837a7
module
Language.Haskell.GHC.HappyParser
(
fullStatement
,
fullImport
,
fullDeclaration
,
fullExpression
,
fullTypeSignature
,
fullModule
)
where
import
GHC.Parser
import
GHC.Types.SrcLoc
-- compiler/hsSyn
import
GHC.Hs
-- compiler/utils
import
GHC.Data.OrdList
-- compiler/parser
import
GHC.Parser.Lexer
import
GHC.Parser.PostProcess
(
ECP
(
..
),
runPV
)
fullStatement
::
P
(
Maybe
(
LStmt
GhcPs
(
LHsExpr
GhcPs
)))
fullStatement
=
parseStmt
fullImport
::
P
(
LImportDecl
GhcPs
)
fullImport
=
parseImport
fullDeclaration
::
P
(
OrdList
(
LHsDecl
GhcPs
))
fullDeclaration
=
fmap
unitOL
parseDeclaration
fullExpression
::
P
(
LHsExpr
GhcPs
)
fullExpression
=
parseExpression
>>=
\
p
->
runPV
$
unECP
p
fullTypeSignature
::
P
(
Located
(
OrdList
(
LHsDecl
GhcPs
)))
fullTypeSignature
=
fmap
(
noLoc
.
unitOL
)
parseTypeSignature
fullModule
::
P
(
Located
HsModule
)
fullModule
=
parseModule
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment