chez-code

chez-code
Login

A collection of libraries and programs written for Chez Scheme.

Libraries

The libs folder contains a number of repackaged libraries, SRFIs and R7RS-large libraries, plus some new libraries under the robin subfolder. For more on these, see the documentation here.

Programs

There are two moderately interesting programs here:

chez script

At the top level is a bash script, named 'chez'. This is a convenience script I use for building and testing Scheme programs.

To use the script, copy it to somewhere on your PATH and make it executable. Edit the two variables at the top:

How to use the script?

$ chez help
chez is a script to help run/compile/test Chez Scheme source code.

Usage:

    chez command [filename]

Commands:

    clean             deletes compiled files in current directory and libraries
    compile filename  compiles the program "filename" and dependent files
    help              this message
    install filename  compiles and installs the program "filename" into bin/
    run filename      runs the given filename
    test [filename]   runs all test files "NAME-test.ss", or the given filename
    version           prints Chez Scheme version

For example, using the procjava program, we could run all the tests in this and child folders:

$ cd procjava
$ chez test
%%%% Starting test lexer  (Writing full log to "lexer.log")
# of expected passes      89
%%%% Closing log file
%%%% Starting test parser  (Writing full log to "parser.log")
# of expected passes      121
%%%% Closing log file

We can then run the parser on an example program:

$ chez run procjava.ss examples/hello.java
Running: examples/hello.java
Hello World

Finally, let's install the interpreter as a standalone program; this step compiles the program into a .prg file, and creates a script to call it, copying both to your CHEZBIN folder.

$ chez install procjava.ss 
compiling procjava.ss with output to procjava.so
compiling lib/interpreter.sls with output to lib/interpreter.so
compiling lib/lexer.sls with output to lib/lexer.so
compiling lib/parser.sls with output to lib/parser.so
creating executable script: bin/procjava
$ ls -l ~/Software/bin/procjava*
-rwxrwxr-x 1 peter peter    62 Nov 27 23:23 /home/peter/Software/bin/procjava
-rw-rw-r-- 1 peter peter 81420 Nov 27 23:23 /home/peter/Software/bin/procjava.prg

The program can now be called from the command line:

$ cd examples
$ procjava hello.java 
Running: hello.java
Hello World

Limitations:

  1. Chez Scheme requires the libraries to be added to a .prg file in a sorted order, based on dependency (any required library must be added before the current one). This order is not respected in the script.
  2. CHEZLIBS in the script only holds one library path. The script could instead use CHEZSCHEMELIBDIRS.

Download

Latest source code: zip - tar.gz

Clone and view this fossil repository using the following commands:

$ fossil clone https://chiselapp.com/user/pcl/repository/chez-code chez-code.fossil
$ mkdir chezcode_folder
$ cd chezcode_folder
$ fossil open ../chez-code.fossil
$ ls
... shows all the files
$ fossil ui
... opens the repository in your browser

Contact

Peter Lane (peterlane@gmx.com)