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
a84934d3
Commit
a84934d3
authored
Feb 24, 2015
by
Ben Gamari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ghc-parser: Kill partial parsers
parent
b1f0d035
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
25 deletions
+10
-25
Parser.hs
ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs
+10
-25
No files found.
ghc-parser/generic-src/Language/Haskell/GHC/Parser.hs
View file @
a84934d3
...
@@ -17,12 +17,6 @@ module Language.Haskell.GHC.Parser (
...
@@ -17,12 +17,6 @@ module Language.Haskell.GHC.Parser (
parserTypeSignature
,
parserTypeSignature
,
parserModule
,
parserModule
,
parserExpression
,
parserExpression
,
partialStatement
,
partialImport
,
partialDeclaration
,
partialTypeSignature
,
partialModule
,
partialExpression
,
-- Haskell string preprocessing.
-- Haskell string preprocessing.
removeComments
,
removeComments
,
...
@@ -71,27 +65,20 @@ data Located a = Located {
...
@@ -71,27 +65,20 @@ data Located a = Located {
}
deriving
(
Eq
,
Show
,
Functor
)
}
deriving
(
Eq
,
Show
,
Functor
)
data
ParserType
=
FullParser
|
PartialParser
data
Parser
a
=
Parser
(
P
a
)
data
Parser
a
=
Parser
ParserType
(
P
a
)
-- Our parsers.
-- Our parsers.
parserStatement
=
Parser
FullParser
Parse
.
fullStatement
parserStatement
=
Parser
Parse
.
fullStatement
parserImport
=
Parser
FullParser
Parse
.
fullImport
parserImport
=
Parser
Parse
.
fullImport
parserDeclaration
=
Parser
FullParser
Parse
.
fullDeclaration
parserDeclaration
=
Parser
Parse
.
fullDeclaration
parserExpression
=
Parser
FullParser
Parse
.
fullExpression
parserExpression
=
Parser
Parse
.
fullExpression
parserTypeSignature
=
Parser
FullParser
Parse
.
fullTypeSignature
parserTypeSignature
=
Parser
Parse
.
fullTypeSignature
parserModule
=
Parser
FullParser
Parse
.
fullModule
parserModule
=
Parser
Parse
.
fullModule
partialStatement
=
Parser
PartialParser
Parse
.
partialStatement
partialImport
=
Parser
PartialParser
Parse
.
partialImport
partialDeclaration
=
Parser
PartialParser
Parse
.
partialDeclaration
partialExpression
=
Parser
PartialParser
Parse
.
partialExpression
partialTypeSignature
=
Parser
PartialParser
Parse
.
partialTypeSignature
partialModule
=
Parser
PartialParser
Parse
.
partialModule
-- | Run a GHC parser on a string. Return success or failure with
-- | Run a GHC parser on a string. Return success or failure with
-- associated information for both.
-- associated information for both.
runParser
::
DynFlags
->
Parser
a
->
String
->
ParseOutput
a
runParser
::
DynFlags
->
Parser
a
->
String
->
ParseOutput
a
runParser
flags
(
Parser
parser
Type
parser
)
str
=
runParser
flags
(
Parser
parser
)
str
=
-- Create an initial parser state.
-- Create an initial parser state.
let
filename
=
"<interactive>"
let
filename
=
"<interactive>"
location
=
mkRealSrcLoc
(
mkFastString
filename
)
1
1
location
=
mkRealSrcLoc
(
mkFastString
filename
)
1
1
...
@@ -115,10 +102,8 @@ runParser flags (Parser parserType parser) str =
...
@@ -115,10 +102,8 @@ runParser flags (Parser parserType parser) str =
let
parseEnd
=
realSrcSpanStart
$
last_loc
parseState
let
parseEnd
=
realSrcSpanStart
$
last_loc
parseState
endLine
=
srcLocLine
parseEnd
endLine
=
srcLocLine
parseEnd
endCol
=
srcLocCol
parseEnd
endCol
=
srcLocCol
parseEnd
(
before
,
after
)
=
splitAtLoc
endLine
endCol
str
in
(
before
,
after
)
=
splitAtLoc
endLine
endCol
str
case
parserType
of
in
Parsed
result
PartialParser
->
Partial
result
(
before
,
after
)
FullParser
->
Parsed
result
-- Convert the bag of errors into an error string.
-- Convert the bag of errors into an error string.
printErrorBag
bag
=
joinLines
.
map
show
$
bagToList
bag
printErrorBag
bag
=
joinLines
.
map
show
$
bagToList
bag
...
...
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