1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
module Curry.Comment where
import Directory (doesFileExist)
import FileGoodies (getFileInPath, lookupFileInPath)
import FilePath (takeFileName, (</>), (<.>))
import System.CurryPath ( lookupModuleSourceInLoadPath, getLoadPathForModule
, inCurrySubdir, stripCurrySuffix )
import System.FrontendExec ( FrontendParams, FrontendTarget (..), defaultParams
, setQuiet, callFrontend, callFrontendWithParams )
import Curry.Span
data = String
| String
deriving (Eq, Ord, Show, Read)
commentString :: Comment -> String
(NestedComment s) = s
commentString (LineComment s) = s
readComments :: String -> IO [(Span, Comment)]
progname =
readCommentsWithParseOptions progname (setQuiet True defaultParams)
readCommentsWithParseOptions :: String -> FrontendParams -> IO [(Span, Comment)]
progname options = do
mbsrc <- lookupModuleSourceInLoadPath progname
case mbsrc of
Nothing -> do
loadpath <- getLoadPathForModule progname
filename <- getFileInPath (commentsFileName (takeFileName progname)) [""]
loadpath
readCommentsFile filename
Just (dir,_) -> do
callFrontendWithParams COMMS options progname
readCommentsFile (commentsFileName (dir </> takeFileName progname))
commentsFileName :: String -> String
prog = inCurrySubdir (stripCurrySuffix prog) <.> "cycom"
readCommentsFile :: String -> IO [(Span, Comment)]
filename = do
filecontents <- readCommentsFileRaw filename
return (read filecontents)
readCommentsFileRaw :: String -> IO String
filename = do
extfcy <- doesFileExist filename
if extfcy
then readFile filename
else do let subdirfilename = inCurrySubdir filename
exdirtfcy <- doesFileExist subdirfilename
if exdirtfcy
then readFile subdirfilename
else error ("EXISTENCE ERROR: Comment file '" ++ filename ++
"' does not exist")
|