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
6038faf1
Commit
6038faf1
authored
May 18, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issues with decl parsing
parent
11130856
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
Test.ipynb
notebooks/Test.ipynb
+6
-12
Parser.hs
src/IHaskell/Eval/Parser.hs
+7
-2
No files found.
notebooks/Test.ipynb
View file @
6038faf1
...
...
@@ -3,7 +3,7 @@
"celltoolbar": "Hiding",
"language": "haskell",
"name": "",
"signature": "sha256:1
a476f19eca338ce4e01b81006d0a165e437bdcebbbea6d1ac10e0cd217740ee
"
"signature": "sha256:1
5cf13f0b51aedf4b16cbd0be35d8f1f0e7cca10ef18411c270d26f993eda4a7
"
},
"nbformat": 3,
"nbformat_minor": 0,
...
...
@@ -44,22 +44,16 @@
"f :: Int -> Int\n",
"f x = x + x\n",
"\n",
"f 3 <<>> f 3"
"f 3 <<>> f 3\n",
"\n",
"f :: Int -> Int\n",
"f x = x + x"
],
"language": "python",
"metadata": {
"hidden": false
},
"outputs": [
{
"metadata": {},
"output_type": "display_data",
"text": [
"18"
]
}
],
"prompt_number": 2
"outputs": []
},
{
"cell_type": "code",
...
...
src/IHaskell/Eval/Parser.hs
View file @
6038faf1
...
...
@@ -25,6 +25,7 @@ import Bag
import
ErrUtils
hiding
(
ErrMsg
)
import
FastString
import
GHC
hiding
(
Located
)
import
GhcMonad
import
Lexer
import
OrdList
import
Outputable
hiding
((
<>
))
...
...
@@ -66,7 +67,7 @@ data DirectiveType
deriving
(
Show
,
Eq
)
-- | Parse a string into code blocks.
parseString
::
GhcMonad
m
=>
String
->
m
[
Located
CodeBlock
]
parseString
::
String
->
Ghc
[
Located
CodeBlock
]
parseString
codeString
=
do
-- Try to parse this as a single module.
flags
<-
getSessionDynFlags
...
...
@@ -77,6 +78,7 @@ parseString codeString = do
-- Split input into chunks based on indentation.
let
chunks
=
layoutChunks
$
removeComments
codeString
result
<-
joinFunctions
<$>
processChunks
[]
chunks
liftIO
$
print
result
-- 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
...
...
@@ -190,7 +192,10 @@ parseCodeChunk code startLine = do
-- signature, which is also joined with the subsequent declarations.
joinFunctions
::
[
Located
CodeBlock
]
->
[
Located
CodeBlock
]
joinFunctions
[]
=
[]
joinFunctions
blocks
=
Located
lnum
(
conjoin
$
map
unloc
decls
)
:
joinFunctions
rest
joinFunctions
blocks
=
if
signatureOrDecl
$
unloc
$
head
blocks
then
Located
lnum
(
conjoin
$
map
unloc
decls
)
:
joinFunctions
rest
else
head
blocks
:
joinFunctions
(
tail
blocks
)
where
decls
=
takeWhile
(
signatureOrDecl
.
unloc
)
blocks
rest
=
drop
(
length
decls
)
blocks
...
...
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