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
9a3bff64
Commit
9a3bff64
authored
Mar 05, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gibiansky/IHaskell
parents
cc5f8953
df8fd579
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
23 deletions
+7
-23
Parser.hs
src/IHaskell/Eval/Parser.hs
+7
-23
No files found.
src/IHaskell/Eval/Parser.hs
View file @
9a3bff64
...
@@ -14,25 +14,14 @@ module IHaskell.Eval.Parser (
...
@@ -14,25 +14,14 @@ module IHaskell.Eval.Parser (
PragmaType
(
..
),
PragmaType
(
..
),
)
where
)
where
-- Hide 'unlines' to use our own 'joinLines' instead.
import
ClassyPrelude
hiding
(
head
,
liftIO
,
maximumBy
)
import
ClassyPrelude
hiding
(
head
,
tail
,
liftIO
,
unlines
,
maximumBy
)
import
Data.List
(
findIndex
,
maximumBy
,
maximum
,
inits
)
import
Data.List
(
maximumBy
,
inits
)
import
Data.String.Utils
(
startswith
,
strip
,
split
)
import
Data.String.Utils
(
startswith
,
strip
,
split
)
import
Data.List.Utils
(
subIndex
)
import
Prelude
(
head
,
tail
)
import
Prelude
(
init
,
last
,
head
,
tail
)
import
Control.Monad
(
msum
)
import
Control.Monad
(
msum
)
import
Bag
import
ErrUtils
hiding
(
ErrMsg
)
import
FastString
import
GHC
hiding
(
Located
)
import
GHC
hiding
(
Located
)
import
GhcMonad
import
Lexer
import
OrdList
import
Outputable
hiding
((
<>
))
import
SrcLoc
hiding
(
Located
)
import
StringBuffer
import
Language.Haskell.GHC.Parser
import
Language.Haskell.GHC.Parser
import
IHaskell.Eval.Util
import
IHaskell.Eval.Util
...
@@ -93,8 +82,9 @@ parseString codeString = do
...
@@ -93,8 +82,9 @@ parseString codeString = do
-- Return to previous flags. When parsing, flags can be set to make
-- Return to previous flags. When parsing, flags can be set to make
-- sure parsing works properly. But we don't want those flags to be
-- sure parsing works properly. But we don't want those flags to be
-- set during evaluation until the right time.
-- set during evaluation until the right time.
setSessionDynFlags
flags
_
<-
setSessionDynFlags
flags
return
result
return
result
otherwise
->
error
"parseString failed, output was neither Parsed nor Failure"
where
where
parseChunk
::
GhcMonad
m
=>
String
->
LineNumber
->
m
(
Located
CodeBlock
)
parseChunk
::
GhcMonad
m
=>
String
->
LineNumber
->
m
(
Located
CodeBlock
)
parseChunk
chunk
line
=
Located
line
<$>
handleChunk
chunk
line
parseChunk
chunk
line
=
Located
line
<$>
handleChunk
chunk
line
...
@@ -124,10 +114,6 @@ parseString codeString = do
...
@@ -124,10 +114,6 @@ parseString codeString = do
isPragma
::
String
->
Bool
isPragma
::
String
->
Bool
isPragma
=
startswith
"{-#"
.
strip
isPragma
=
startswith
"{-#"
.
strip
-- Number of lines in this string.
nlines
::
String
->
Int
nlines
=
length
.
lines
activateExtensions
::
GhcMonad
m
=>
CodeBlock
->
m
()
activateExtensions
::
GhcMonad
m
=>
CodeBlock
->
m
()
activateExtensions
(
Directive
SetExtension
ext
)
=
void
$
setExtension
ext
activateExtensions
(
Directive
SetExtension
ext
)
=
void
$
setExtension
ext
activateExtensions
(
Directive
SetDynFlag
flags
)
=
activateExtensions
(
Directive
SetDynFlag
flags
)
=
...
@@ -193,6 +179,7 @@ parseCodeChunk code startLine = do
...
@@ -193,6 +179,7 @@ parseCodeChunk code startLine = do
tryParser
string
(
blockType
,
parser
)
=
case
parser
string
of
tryParser
string
(
blockType
,
parser
)
=
case
parser
string
of
Parsed
res
->
Parsed
(
blockType
res
)
Parsed
res
->
Parsed
(
blockType
res
)
Failure
err
loc
->
Failure
err
loc
Failure
err
loc
->
Failure
err
loc
otherwise
->
error
"tryParser failed, output was neither Parsed nor Failure"
parsers
::
DynFlags
->
[(
String
->
CodeBlock
,
String
->
ParseOutput
String
)]
parsers
::
DynFlags
->
[(
String
->
CodeBlock
,
String
->
ParseOutput
String
)]
parsers
flags
=
parsers
flags
=
...
@@ -297,7 +284,4 @@ getModuleName moduleSrc = do
...
@@ -297,7 +284,4 @@ getModuleName moduleSrc = do
case
unLoc
<$>
hsmodName
(
unLoc
mod
)
of
case
unLoc
<$>
hsmodName
(
unLoc
mod
)
of
Nothing
->
error
"Module must have a name."
Nothing
->
error
"Module must have a name."
Just
name
->
return
$
split
"."
$
moduleNameString
name
Just
name
->
return
$
split
"."
$
moduleNameString
name
otherwise
->
error
"getModuleName failed, output was neither Parsed nor Failure"
-- Not the same as 'unlines', due to trailing \n
joinLines
::
[
String
]
->
String
joinLines
=
intercalate
"
\n
"
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