cyc-0.9.11

Langue: en

Autres versions - même langue

Version: 369960 (fedora - 01/12/10)

Section: 1 (Commandes utilisateur)


BSD mandoc

NAME cyc , cyc-0.9.11

- A native code compiler for Curry.

SYNOPSIS

[option ... ] file ...

DESCRIPTION

is a native code compiler for the multi-paradigm declarative language Curry. Normally, it performs compilation, assembly, and linking. The ``overall options'' allow stopping this process at an intermediate stage. For example, the -c option says not to run the linker. The output then consists of object files output by the assembler.

Other options control one stage of processing; for instance, the --debug option tells cyc to compile Curry modules such that they can be evaluated by the declarative debugger.

The program accepts options and file names as operands. Options and file names can be mixed on the command line. In general, the order of options is not relevant with the exception of additional libraries specified with -l options. On many systems, these should be specified last on the command line in order to ensure proper linking of programs.

The source language of a file and the associated processing is determined by the file name extension. Argument names which end with .curry are taken to be Curry source, names ending in .lcurry are taken to be literate Curry source, names ending in .c are taken to be C code, names ending in .s are taken to be assembler programs, and .o are object files.

By default, a program linked with cyc executes the main function in the main module of the program. The compiler assumes that the last Curry source file appearing on the command line defines the main module. A different main module can be specified explicitly with the -M option. It is possible to specify a different goal with the -e option. If the type of the goal is IO t for some arbitrary type t the program executes the corresponding I/O action. Otherwise, the goal is evaluated and its solutions are presented incrementally on the standard output.

Overall Options

The following options control the general processing of source files.
-n
Do not execute any command, but display each command that normally would be executed.
-q
This option has no effect.
-v
Display each command before it is executed by .
-C
Stop processing after generating C code from the Curry source modules.
-S
Stop processing after generating assembler code from the Curry and C source files.
-c
Compile and assemble the source file but do not link.
-o file
Place the output in a file named file Since only one output file can be specified, it does not make sense to use -o when compiling more than one input file unless you are producing an executable file as output.

If -o is not specified, the default is to put an executable file in a.out the object file for source .suffix in source .o its assembler file in source .s and its C file in source .c

-arch arch
Mac OS X: Compile for the specified target architecture arch Multiple options work, and direct the compiler to produce ``universal'' binaries. Using this option on other systems is likely to produce a C compiler error.

Compiling Curry Modules

The names of Curry source files must end with .curry or .lcurry The latter are taken to contain literate Curry source and are deliterated first. All Curry source files are compiled into C code. In addition, for every source file file .curry and file .lcurry respectively, the compiler creates a file file .icurry containing the module's interface. The compiler uses module interfaces when processing import declarations in a source module. In order for the compiler to find the interfaces of imported modules, the name of the source file should agree with its module name. Hierarchical module names of the form A.B.C are mapped onto the filesystem as in Java, i.e., the compiler expects to find the interface of this module in file C.icurry in directory A/B relative to the directory where the compiler was invoked or to one of the directories specifying the import search path.

The following options control the compilation of Curry source into C code.

-g
Deprecated synonym for --debug
--debug
Prepare the compiled code for executing the program with the declarative debugger.

Note that code compiled with this option is incompatible with code compiled without this option. This option must therefore be used consistently for compiling and linking all modules of a program.

--trusted
This flag has an effect only in conjunction with one of previous options. It tells that debugger that it can trust all functions from a module compiled with this flag. The debugger will not ask questions about such functions.
-i dir
Add directory dir to the list of paths used to locate interface files. By default, the compiler searches for interface files in the current directory and in its standard library directory /usr/lib64/curry-0.9.11

The directory dir is also added to the list of paths used to locate header files, as if -I dir was present on the command line.

-P dir
Add directory dir to the list of paths used to locate interface files. By default, the compiler searches for interface files in the current directory and in its standard library directory /usr/lib64/curry-0.9.11

The directory dir is also added to the lists of paths used to locate header and library files, respectively, as if -I dir and -L dir were present on the command line.

-Whaskell
-Wprolog
-Wgoedel
Warn whenever a definition does not obey the selected case mode (cf. Sect. C.1 of the Curry report).
-Wall

 Enable all warnings below.
-Wunused
Enable all unused warnings below.
-Wunused-data
Warn whenever a data constructor is not used.
-Wunused-decl
Warn whenever a function or pattern declaration is not used.
-Wunused-var
Warn whenever a function or pattern argument is not used.
-Wshadow
Warn whenever a local declaration shadows a declaration from an outer scope.
-Woverlap
Warn whenever a function's equations have overlapping left hand sides.
-H size
Change the heap size used by the compiler to size It is possible to use the abbreviations size k and size M to specify the heap size in kBytes and MBytes, respectively.

Note that this option does not effect the heap size of the compiled executable. Use -h size for this (see below).

Compiling C Files

The following list describes only the most common options understood by when compiling C source either directly or as a result of previously compiling Curry source into C code. In fact, passes on most of its options to the C compiler. For a detailed description of these options see the gcc(1) man page.
-D name
Predefine name as a macro, with definition 1
-D name=defn
Predefine name as a macro with definition defn
-U name
Cancel any previous definition of name either built in or provided with a -D definition.
-I dir
Add directory dir to the list of paths used to locate header files. The standard library directory ( /usr/lib64/curry-0.9.11 is always included in this list.
-F dir
Mac OS X: Add the framework directory dir to the list of paths used to locate header files. Using this option on other systems is likely to produce a C compiler error.
-O
equivalent to -O1
-O level
Controls optimization of the compiled code. -O0 disables all optimizations. Note that -O3 and higher levels will fail to produce valid code for Curry modules on many architectures.
--ccopt opt
Passes the option opt to the C compiler without interpretation. For instance, in order to include debugging symbols in the compiled C code, invoke the compiler with --ccopt -g
--ccopts opts
Passes each option from the comma separated list opts to the C compiler without further interpretation.

Linking

The following options are relevant while linking a program. The compiler creates a tiny C code file in this phase, which contains the startup code initializing the Curry runtime system and starting the evaluation of the goal. This file is compiled like other C code during the link phase.
-g
Deprecated synonym for --debug
--debug
Compile a program that invokes the declarative debugger. All Curry modules must have been compiled with the --debug option as well.
-h size
Use size bytes for the heap of the Curry program. Note that actually twice as much memory is allocated for the heap because the runtime system uses a two-space copying collector. The abbreviations size k and size M can be used for specifying the size in kBytes and MBytes, respectively. The default is to use a 4 MByte heap.
-k size
Use size bytes for the stack of the Curry program. The abbreviations size k and size M can be used for specifying the size in kBytes and MBytes, respectively. The default is to use a 512 kByte stack.
-t size
Use size bytes for the trail stack of the Curry program. The abbreviations size k and size M can be used for specifying the size in kBytes and MBytes, respectively. The default is to use a 512 kByte trail stack.
-f
Print all failures during execution of a non-deterministic goal. If given multiple times, print also failures inside encapsulated search.
-p
Print cumulated execution times and memory usage statistics at the end of the run. If specified more than once, also print memory statistics at each garbage collection.
-e goal
Evaluate goal instead of main The goal is evaluated with respect to the modules specified with -M options and the Curry source files appearing on the command line. All entities exported from the Prelude and the Curry source file that appears last on the command line or the last module specified with a -M option, if there are no source file arguments, are in scope with unqualified and qualified names. The exported entities of all other modules are in scope with qualified names only.
-T goal
Compute the type of goal The goal 's type is computed with respect to the modules specified with -M options and the Curry source files appearing on the command line. All entities exported from the Prelude and the Curry source file that appears last on the command line or the last module specified with a -M option, if there are no source file arguments, are in scope with unqualified and qualified names. The exported entities of all other modules are in scope with qualified names only.
-M module
Brings all entities exported from module into scope with their qualified names for a goal specified with the -e and -T options. By default, only the entities exported from the Prelude and the Curry source files occurring on the command line are in scope. The entities exported from the Prelude and the last source file appearing on the command line or specified with the last -M option, if there are no source file arguments, are brought into scope with their unqualified names, too.

Module is either the name of a source file (ending in .lcurry or .curry ) the name of an interface file (ending in .icurry ) or the name of a module whose interface can be located in the interface search path.

-L dir
Add directory dir to the list of paths used to locate libraries specified with -l options. The standard library directory /usr/lib64/curry-0.9.11 is always included in this list.
-l lib
Search the library named lib when linking.
-framework name
Mac OS X: Link against framework name Using this option on other systems is likely to produce a C compiler error.
--ldopt opt
Passes the option opt to the C compiler without interpretation. In contrast to --ccopt (see above), opt is used only during the link phase.
--ldopts opts
Passes each option from the comma separated list opts to the C compiler without further interpretation. As with --ldopt opts are used only during the link phase.

Running Programs

The operation of a Curry program depends on the type of the goal being evaluated. If it is of type IO t the I/O action described by the goal is executed. All command line arguments except for the runtime system options (see below) are available to the program and can be accessed with the function System.getArgs

If the goal's type is not IO t the program computes and prints the solutions of the goal with a depth first search strategy. A solution comprises the normal form of the goal and the bindings and constraints for its free variables. When run on an interactive terminal, solutions are presented one by one giving the user a chance to stop the computation after each solution. Otherwise, all solutions of the goal are computed.

This behavior can be changed by passing one of the options -i and -n to the program. If invoked with -i the program computes the solutions incrementally as if it were run on an interactive terminal. If invoked with -n the goal's solutions are computed all at once.

All Curry programs run with fixed size heap, stack, and trail. Their sizes can be specified at link time, but can be changed at run-time by passing options to the Curry runtime system. Such options must be enclosed with +RTS and -RTS arguments on the command line. The -RTS switch may be omitted if it is the last argument on the command line.

The Curry runtime system understands the following options:

-b mode
Use buffer mode mode for the standard input and output of the program where the following mode s are recognized
n
Unbuffered
l
Line buffered
f n
Fully buffered

The optional number n allows specifying the buffer size when using fully buffered mode.

-h n
Use n bytes for the heap in this run of the program. Note that actually twice as much memory is allocated for the heap because the runtime system uses a two-space copying collector. The abbreviations n k and n M can be used for specifying the size in kBytes and MBytes, respectively.
-k n
Use n bytes for the stack in this run of the program. The abbreviations n k and n M can be used for specifying the size in kBytes and MBytes, respectively.
-t n
Use n bytes for the trail stack in this run of the program. The abbreviations n k and n M can be used for specifying the size in kBytes and MBytes, respectively.
-f
Print all failures during execution of a non-deterministic goal. If given multiple times, print also failures inside encapsulated search.
-p
Print cumulated execution times and memory usage statistics at the end of the run. If specified more than once, also print memory statistics at each garbage collection.
-d
Turn on the low-level tracer of the abstract machine. In general you do not want to see its output, but it may give hints to why a program does not compute an expected solution or runs into a deadlock. Beware that tracing can slow down program execution considerably and the output may be excessively large.

ENVIRONMENT

CURRY_PATH
The environment variable CURRY_PATH is used to locate the compiler executables. The default value is /usr/lib64/curry-0.9.11
CURRY_IMPORT_PATH
CURRY_INCLUDE_PATH
CURRY_LIBRARY_PATH
The environment variables CURRY_IMPORT_PATH CURRY_INCLUDE_PATH and CURRY_LIBRARY_PATH contain colon-separated lists of directories that are searched for imported interfaces, included header files, and library files, respectively. Their default value is $CURRY_PATH

FILES

/usr/lib64/curry-0.9.11/cycc
The Curry to C compiler.
/usr/lib64/curry-0.9.11/*.icurry , /usr/lib64/curry-0.9.11/*.h
Interface and header files for the standard library and runtime system of the Curry compiler.
/usr/lib64/curry-0.9.11/libcurry.a
The runtime system and standard library.
/usr/lib64/curry-0.9.11/libcurry_g.a
Standard library prepared for debugging. All library modules have been compiled with --trusted

EXAMPLES

cyc test.curry
This command compiles and links the Curry module in test.curry The executable is put in a.out and evaluates the main function in test.curry
cyc -h12M -O2 A.lcurry B.lcurry -o B
This command compiles and links the Curry modules in A.lcurry and B.lcurry in that order. Both files are assumed to contain literate Curry source. The code is optimized by the C compiler using optimization level 2. The executable is put in file B It evaluates the main function in B.lcurry and uses a larger default heap (12 MBytes).
cyc -c nat.curry
cyc -e add n Z =:= S Z where n free nat.o -Mnat -o one
The first of these commands compiles the Curry module in nat.curry and places the object file in nat.o The second command then links the object file into a program which evaluates the goal add n Z =:= S Z where n free in the context of this module. Note that this context must be specified explicitly with a -M option because no Curry module was named on the second command line. The executable is placed in one
cyc -e length Xs where Xs free
This command compiles and links a program that evaluates the goal length Xs where Xs free The executable is placed in a.out
a.out -x +RTS -k512k -h8M -t0 -RTS foo
executes a.out with an 8 MByte heap, a 512 kByte stack, and no trail stack. The arguments -x and foo are passed to the Curry program and are available from Curry code via System.getArgs Note that running a program without a trail stack, as in this example, requires that the code is completely deterministic and does not use encapsulated search.

SEE ALSO

cyi(1), cymake(1), gcc(1)