JucsREPL.curry 2.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
--- A REPL for the [Curry->Julia compiler](http://arxiv.org/abs/2008.11999)
--- based on the universal REPL for Curry compilers.
--- 
--- The REPL can be compiled into an executable by
---
---     > cypm curry :l JucsREPL.curry :save :q
---
--- @author  Michael Hanus
10
--- @version June 2021
11
12
13
14
15
16
------------------------------------------------------------------------------

module JucsREPL where

import Curry.Compiler.Distribution ( installDir )
import Data.List         ( intercalate )
17
import System.CurryPath ( inCurrySubdir, modNameToPath, sysLibPath )
18
19
20
21
22
23
24
25
26
27
28

import REPL.Compiler
import REPL.Main         ( mainREPL )

main :: IO ()
main = mainREPL jucs

--- Specification of the Curry->Go compiler:

jucs :: CCDescription
jucs = CCDescription
29
  "jucs"                               -- the compiler name
30
  (1,0,0)                              -- the version number
31
32
33
  jucsBanner                           -- the banner
  jucsHome                             -- home directory of the compiler
  "info@curry-lang.org"                -- contact email
Michael Hanus's avatar
Michael Hanus committed
34
  (installDir ++ "/bin/pakcs-frontend") -- executable of the Curry front end
35
36
  "jucs"                               -- compiler executable
  (installDir ++ "/lib")               -- base library path
37
  (Just False)                         -- load command reads untyped FlatCurry
38
39
40
41
42
43
  True                                 -- use CURRYPATH variable
  (\s -> "-v" ++ s)                    -- option to pass verbosity
  (\_ -> "")                           -- option to pass parser options
  (\s -> s)                            -- option to compile only
  (\s -> "--standalone -m main " ++ s) -- option to create an executable
  cleanCmd                             -- command to clean module
44
  [stratOpt, intOpt, firstOpt]
45
46
47
48
 where
  cleanCmd m =
    "/bin/rm -f " ++ inCurrySubdir m ++ ".* " ++ modNameToPath m ++ ".curry "
                  ++ modNameToPath m ++ ".jl"
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

jucsHome :: String
jucsHome = "/usr/lib/curry2julia"

jucsBanner :: String
jucsBanner = unlines [bannerLine, bannerText, bannerLine]
 where
  bannerText = "Curry->Julia Interactive Environment"
  bannerLine = take (length bannerText) (repeat '-')

stratOpt :: CCOption
stratOpt = CCOption
  "dfs/bfs     "
  "search strategy (depth-first / breadth-first)"
  [ ("dfs","--dfs")
  , ("bfs","--bfs")
  ]

intOpt :: CCOption
intOpt = CCOption
  "+/-interactive "
  "turn on/off interactive evaluation of main expression"
  [ ("-interactive","")
  , ("+interactive","--interactive")
  ]

firstOpt :: CCOption
firstOpt = CCOption
  "+/-first       "
  "turn on/off printing only first value/solution"
  [ ("-first","")
  , ("+first","--first")
  ]

------------------------------------------------------------------------------