Commit a3380c1f authored by Michael Hanus's avatar Michael Hanus
Browse files

Comments and explanations updated

parent 701232b1
curry-repl
==========
curry-repl: A universal interactive environment for Curry compilers
===================================================================
This package contains the implementation of a
universal REPL (Read-Eval-Print-Loop) which can be used
......@@ -20,23 +20,26 @@ Requirements for a Curry Compiler used by a REPL
Basically, the REPL translates each expression to be evaluated
into a program with a `main` operation. This program is
compiled and then executed. In order to implement this
kind of REPL, it should be possible to invoke the Curry compiler `cc`
as follows:
kind of REPL, it should be possible to invoke the Curry
compiler `curryc` as follows:
cc [-vn] [-iDIR] ... [-iDIR] [--parse-options="PO"] [-c|--compile] MOD
curryc [-vn] [-iDIR] ... [-iDIR] [--parse-options="PO"] [-c|--compile] MOD
* `-vn`: verbosity with 0<=n<=4
where the possible arguments are:
* `-vn`: verbosity with `0 <= n <= 4`
* `-iDIR`: use `DIR` to search for imported modules
* `-c`: compile only
* `PO`: options passed to the Curry front end
* `PO`: additional options passed to the Curry front end
* `MOD`: the module to be compiled containing an operation `main`
This command should compile module `MOD` (and, if necessary,
all imported modules) and create an executable `MOD` which
executes the operation `main` in this module. `MOD` might
be a hierarchical module name, e.g., `Dir.Mod`. In this case,
the executable `Dir.Mod` is generated where the source code
of the module is stored in `Dir/Mod.curry`.
the executable `Dir.Mod` is generated relative to the source directory,
e.g., if the source code of the module is stored in `Dir/Mod.curry`,
the executable is stored in the file `Dir.Mod`.
If the option `-c` or `--compile` is provided,
the executable is not generated.
......@@ -73,18 +76,18 @@ The actual options are specified by data of type `CCOption`
Requirements for Curry Compilers used by CPM
============================================
In order to use a Curry compiler together with CPM,
it has to support some options so that CPM can interact
with the compiler. The Curry REPL implements these options
provided that the Curry compiler itself provides options
about its version. If `cc` is the executable of the compiler,
the following options must exist:
In order to use a Curry compiler together with the Curry Package
Manager CPM, it has to support some options so that CPM can interact
with the compiler. The Curry REPL implements these options provided
that the Curry compiler itself provides options about its version. If
`curryc` is the executable of the compiler, the following options must
exist:
* `cc --compiler-name`: Shows that name of the compiler (which occurs
* `curryc --compiler-name`: Shows that name of the compiler (which occurs
in compiler dependencies of package specifications) and quits.
* `cc --numeric-version`: Shows the compiler version quits.
* `cc --base-version`: Shows the version of the base libraries implemented
by the compiler and quits.
* `curryc --numeric-version`: Shows the compiler version quits.
* `curryc --base-version`: Shows the version of the base libraries
implemented by the compiler and quits.
These options can also be combined. In this case the information
is shown in subsequent lines, as shown in this example
......@@ -95,7 +98,8 @@ for [PAKCS](http://www.informatik.uni-kiel.de/~pakcs/):
3.3.0
3.0.0
The intermediate files produced by the compiler should be
In order to support the use of different Curry compilers in parallel,
the intermediate files produced by the compiler should be
stored in the directory
.curry/<compiler-name>-<numeric-version>
......@@ -103,6 +107,15 @@ stored in the directory
relative to the directory of the source file.
If the source file is a hierarchical module,
the same hierarchy is used relative to `.curry`.
For instance, if the PAKCS compiler version 3.3.0 is used
to compile a hierarchical module `Dir.Mod` stored in the
file
/home/curry/base/Dir/Mod.curry
the Prolog target file is stored in
/home/curry/base/.curry/pakcs-3.3.0/Dir/Mod.pl
Running programs
......@@ -115,6 +128,9 @@ executable of the Curry system. Usually, when a Curry system
is started, it should query CPM (by `cypm deps -p`) to get
the value of `CURRYPATH` to load modules. The option `--nocypm`
is intended to turn off this behavior.
Since the querying of CPM is usually done by a separate shell script
to invoke the REPL, the implementation of this REPL just ignores
the option `--nocypm`.
Installing executables
......@@ -123,7 +139,7 @@ Installing executables
If CPM installs an executable, it passes the following options
(REPL commands) to the compiler:
> cc :set v0 :load MAINMOD :save :quit
> curryc :set v0 :load MAINMOD :save :quit
(where `v0` is replaced by `v1` in debug mode).
The execution of this command should install the executable `MAINMOD`.
......@@ -6,43 +6,47 @@
--- a JSON file) or statically defined in some module.
---
--- @author Michael Hanus
--- @version March 2021
--- @version April 2021
------------------------------------------------------------------------------
module REPL.Compiler where
--- The description of a Curry compiler.
--- The name `ccName` should be a sequence of alphanumeric characters and
--- is used for naming resource files, main modules etc.
--- The version `ccVersion` of the compiler is used by the front end
--- and determines auxiliary directory names.
--- The banner `ccBanner` is shown at start up (if verbosity is not quiet).
--- `ccHome` is the home directory of the compiler.
--- This directory should contain a file `<ccName>rc.default`
--- with the template for a resource configuration file.
--- This is copied into the user's home directory or updated.
--- `ccExec` is the executable of the Curry compiler.
--- `ccLibPath` is the path (possibly several directies) containing
--- the base libraries of the Curry compiler. This path will be appended
--- to an existing load path (specified by the envrionment variable
--- `CURRYPATH`).
--- `ccTypedFC` should be set to `True` if the front end should read
--- Typed FlatCurry files instead of FlatCurry files.
--- If `ccCurryPath` is `True`, then the actual load path is passed
--- by the environment variable to the compiler, otherwise it is passed
--- by a sequence of `-iDIR` options.
--- `ccVerbOpt` maps the actual verbosity to the compiler option to pass the
--- verbosity to the compiler command.
--- `ccParseOpt` maps the actual parser options to the compiler option
--- to pass further parser options.
--- `ccCmplOpt` maps the module name to the compiler option
--- to compile a module without creating an executable.
--- `ccExecOpt` maps the module name to the compiler option
--- to compile a module and create an executable having the same
--- name as the module.
--- `ccCleanCmd` maps the module name to the system command which
--- removes the module and all generated intermediate files.
--- `ccOpts` is the list of additional options supported by the compiler.
--- Data type for the specification of a Curry compiler invoked by the REPL.
--- It contains the following components:
---
--- * The name `ccName` should be a sequence of alphanumeric characters and
--- is used for naming resource files, main modules etc.
--- * The version `ccVersion` of the compiler is used by the front end
--- and determines auxiliary directory names.
--- * The banner `ccBanner` is shown at start up (if verbosity is not quiet).
--- * `ccHome` is the home directory of the compiler.
--- This directory should contain a file `<ccName>rc.default`
--- with the template for a resource configuration file.
--- This file is copied into the user's home directory (if it does not exist)
--- or updated (when the variables in the template have been changed).
--- * `ccExec` is the executable of the Curry compiler.
--- * `ccLibPath` is the path (possibly several directies) containing
--- the base libraries of the Curry compiler. This path will be appended
--- to an existing load path (specified by the envrionment variable
--- `CURRYPATH`).
--- * `ccTypedFC` should be set to `True` if the front end should read
--- Typed FlatCurry files instead of FlatCurry files.
--- * If `ccCurryPath` is `True`, then the actual load path is passed
--- by the environment variable `CURRYPATH` to the compiler,
--- otherwise it is passed by a sequence of options of the form `-iDIR`.
--- * `ccVerbOpt` maps the actual verbosity to the compiler option to pass the
--- verbosity to the compiler command.
--- * `ccParseOpt` maps the actual parser options to the compiler option
--- to pass further parser options.
--- * `ccCmplOpt` maps the module name to the compiler option
--- to compile a module without creating an executable.
--- * `ccExecOpt` maps the module name to the compiler option
--- to compile a module and create an executable having the same
--- name as the module.
--- * `ccCleanCmd` maps the module name to the system command which
--- removes the module and all generated intermediate files.
--- * `ccOpts` is the list of additional options supported by the compiler.
data CCDescription = CCDescription
{ ccName :: String -- the name of the compiler
, ccVersion :: (Int,Int,Int) -- major/minor/revision version
......
......@@ -77,7 +77,8 @@ processArgsAndStart rst []
processArgsAndStart rst (arg:args)
-- ignore empty arguments which can be provided by single or double quotes
| null arg = processArgsAndStart rst args
-- ignore '--nocypm' or '--noreadline' (already processed by script)
-- ignore '--nocypm' or '--noreadline'
-- (since they already processed by separate script to invoke the REPL)
| arg == "--nocypm" || arg == "--noreadline"
= processArgsAndStart rst args
| arg == "-V" || arg == "--version"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment