Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
94440029
Commit
94440029
authored
Apr 22, 2014
by
Björn Peemöller
Browse files
Improved internal structure for HTML generation
parent
6387b29b
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/CurryBuilder.hs
View file @
94440029
...
...
@@ -13,7 +13,7 @@
This module contains functions to generate Curry representations for a
Curry source file including all imported modules.
-}
module
CurryBuilder
(
buildCurry
,
smake
)
where
module
CurryBuilder
(
buildCurry
)
where
import
Control.Monad
(
liftM
)
import
Data.Maybe
(
catMaybes
,
mapMaybe
)
...
...
src/Frontend.hs
View file @
94440029
{- |
Module : $Header$
Description : API to access cymake as a library
Copyright : (c) 2005
,
Martin Engelke
(men@informatik.uni-kiel.de)
2011
,
Björn Peemöller
(bjp@informatik.uni-kiel.de)
Copyright : (c) 2005
Martin Engelke
2011
- 2014
Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
...
...
@@ -16,19 +16,14 @@ module Frontend (parse, fullParse) where
import
Control.Monad.Writer
import
Control.Monad.Trans.Either
import
Data.Maybe
(
mapMaybe
)
import
qualified
Data.Map
as
Map
(
empty
)
import
Curry.Base.Message
import
Curry.Files.Filenames
import
Curry.Files.PathUtils
import
Curry.Syntax
(
Module
(
..
),
parseModule
)
import
Curry.Syntax
(
Module
(
..
),
parseModule
)
import
CompilerOpts
(
Options
(
..
),
defaultOptions
)
import
CurryBuilder
(
smake
)
import
CurryDeps
(
Source
(
..
),
flattenDeps
,
moduleDeps
)
import
Modules
(
checkModule
,
checkModuleHeader
,
compileModule
,
loadModule
)
import
CompilerOpts
(
Options
(
..
),
defaultOptions
)
import
CurryBuilder
(
buildCurry
)
import
Modules
(
loadAndCheckModule
,
checkModuleHeader
)
{- |Return the result of a syntactical analysis of the source program 'src'.
The result is the syntax tree of the program (type 'Module'; see Module
...
...
@@ -51,43 +46,21 @@ parse fn src = parseModule fn src >>= genCurrySyntax
be defined using the argument 'paths'.
-}
fullParse
::
Options
->
FilePath
->
String
->
MessageIO
Module
fullParse
opts
fn
src
=
genFullCurrySyntax
opts
fn
$
parse
fn
src
genFullCurrySyntax
::
Options
->
FilePath
->
MessageM
Module
->
MessageIO
Module
genFullCurrySyntax
opts
fn
m
=
case
runMsg
m
of
Left
err
->
failWith
$
show
err
Right
(
mod1
,
_
)
->
do
errs
<-
liftIO
$
makeInterfaces
opts
fn
mod1
fullParse
opts
fn
_
=
do
errs
<-
liftIO
$
makeInterfaces
opts
fn
if
null
errs
then
do
checked
<-
liftIO
$
runEitherT
$
load
Module
opts
fn
>>=
c
heckModule
opts
checked
<-
liftIO
$
runEitherT
$
load
AndC
heckModule
opts
fn
case
checked
of
Left
errs'
->
failWith
$
show
$
head
errs'
Right
(
_
,
mod'
)
->
return
mod'
else
failWith
$
show
$
head
errs
-- TODO: Resembles CurryBuilder
-- Generates interface files for importes modules, if they don't exist or
-- if they are not up-to-date.
makeInterfaces
::
Options
->
FilePath
->
Module
->
IO
[
Message
]
makeInterfaces
opts
fn
mdl
=
do
res
<-
runEitherT
$
do
(
deps1
,
errs
)
<-
fmap
flattenDeps
$
moduleDeps
opts
Map
.
empty
fn
mdl
when
(
null
errs
)
$
mapM_
(
compile
deps1
.
snd
)
deps1
return
errs
makeInterfaces
::
Options
->
FilePath
->
IO
[
Message
]
makeInterfaces
opts
fn
=
do
res
<-
runEitherT
$
buildCurry
opts
fn
case
res
of
Left
errs
->
return
errs
Right
errs
->
return
errs
where
compile
deps'
(
Source
file'
mods
)
=
smake
[
flatName
file'
,
flatIntName
file'
]
(
file'
:
mapMaybe
(
flatInterface
deps'
)
mods
)
(
compileModule
opts
file'
)
(
return
()
)
compile
_
_
=
return
()
flatInterface
deps'
mod1
=
case
lookup
mod1
deps'
of
Just
(
Source
f
_
)
->
Just
$
flatIntName
$
dropExtension
f
Just
(
Interface
f
)
->
Just
$
flatIntName
$
dropExtension
f
_
->
Nothing
Right
_
->
return
[]
src/Html/CurryHtml.hs
View file @
94440029
...
...
@@ -19,8 +19,8 @@ import Data.Maybe (fromMaybe, isJust)
import
Curry.Base.Ident
(
QualIdent
(
..
),
unqualify
)
import
Curry.Base.Message
(
fromIO
)
import
Curry.Base.Pretty
(
text
)
import
Curry.Files.
PathUtils
(
readModule
,
lookupCurryFile
,
dropExtension
,
takeFileNam
e
)
import
Curry.Files.
Filenames
(
dropExtension
,
takeFileName
)
import
Curry.Files.PathUtils
(
readModule
,
lookupCurryFil
e
)
import
Curry.Syntax
(
lexSource
)
import
Html.SyntaxColoring
...
...
src/Modules.hs
View file @
94440029
...
...
@@ -4,7 +4,7 @@
Copyright : (c) 1999 - 2004 Wolfgang Lux
2005 Martin Engelke
2007 Sebastian Fischer
2011 - 201
3
Björn Peemöller
2011 - 201
4
Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
...
...
@@ -15,7 +15,7 @@
-}
module
Modules
(
compileModule
,
load
Module
,
c
heckModule
Header
,
checkModule
,
writeOutput
(
compileModule
,
load
AndC
heckModule
,
checkModule
Header
)
where
import
qualified
Control.Exception
as
C
(
catch
,
IOException
)
...
...
@@ -75,12 +75,16 @@ import Transformations
-- The compiler automatically loads the prelude when compiling any
-- module, except for the prelude itself, by adding an appropriate import
-- declaration to the module.
compileModule
::
Options
->
FilePath
->
CYIO
()
compileModule
opts
fn
=
do
(
env
,
mdl
)
<-
loadAndCheckModule
opts
fn
liftIO
$
writeOutput
opts
fn
(
env
,
mdl
)
loadAndCheckModule
::
Options
->
FilePath
->
CYIO
(
CompilerEnv
,
CS
.
Module
)
loadAndCheckModule
opts
fn
=
do
(
env
,
mdl
)
<-
loadModule
opts
fn
>>=
checkModule
opts
warn
(
optWarnOpts
opts
)
$
warnCheck
opts
env
mdl
liftIO
$
writeOutput
opts
f
n
(
env
,
mdl
)
retur
n
(
env
,
mdl
)
-- ---------------------------------------------------------------------------
-- Loading a module
...
...
src/cymake.hs
View file @
94440029
...
...
@@ -2,7 +2,7 @@
Module : $Header$
Description : Main module
Copyright : (c) 2005 Martin Engelke
2011 - 201
3
Björn Peemöller
2011 - 201
4
Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
...
...
Write
Preview
Supports
Markdown
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