http://people.csail.mit.edu/jaffer/Schlep/scm2java.html | ||||||
Scm2java | ||||||
|
Usage: scm2java [-p constant ] file1.scm file2.scm ... Usage: scm2java [-p constant ] file1.scm file2.scm ... dir/ Translates Scheme files file1.scm, file2.scm, ... to dir/Filen.java and dir/Filen.txi. http://people.csail.mit.edu/jaffer/Schlep/scm2java
Scm2java is a Scheme to Java translator for a subset of Scheme. Using Scheme files as source, scm2java produces texinfo documentation and formatted Java code preserving comments; and type, function, and variable names as much as possible. The output from scm2java is human-readable and can form the base for further development in Java; abandoning the original Scheme source.
The Scheme subset supported by scm2java is listed at
http://people.csail.mit.edu/jaffer/Schlep/#Schlep Subset.
Scheme integers and real numbers, booleans, chars, and strings are
translated to the equivalent Java types. SLIB byte vectors map to
the type byte[]
in Java code. Vectors of user defined (Java)
types are supported.
The user incorporates custom Java data types by coding their definitions and accessors in a Java source file. For the purposes of running in Scheme, put analogous definitions in a file which is not translated by scm2java.
Characters in variable names are translated as follows:
`%' | => | `_Percent' |
`@' | => | `_At' |
`->' | => | `To' |
`=' | => | `Equal' |
`>' | => | `More' |
`<' | => | `Less' |
`?' | => | `_P' |
`:' | => | `_' |
`-' | => | `' |
Scm2java does not include support for a Scheme runtime. Generated Java programs should not assume general Scheme values unless linked with a library providing these features.
Scheme identifier names are used to determine the Java types of the corresponding variables and methods.
Defmacros transforming Scheme code to Scheme code may be defined in
Scheme source files. If there are defmacros used in more than one
Scheme source file, they can be removed to a separate file, and that
file imported by a call to defmacro:load
in each file (before
a defmacro is invoked).
Imports defmacro
s from filename.
Is an alist associating defmacro names with their transformers. It
is fluid-let
during each file translatation, so that scm2java
macro definitions do not take effect in the Scheme top level.
(glob type)
.
glob is a match string; type an expression. Globs
are matched to variable names with trailing digits removed.
Declarations made later override those made earlier.
Declarations can be made by a call to declare-names
. If
no declarations have been made before schlep
is called,
schlep
will read a list of declarations from a file named
`schlep.typ' if it exists in the same directory as the Scheme
file being translated.
If the type is a symbol or string, variables which match the glob string will be declared as types of that name. If the type is a list, then it will be interpreted as follows.
(ptr type)
* type
.
(array type)
type[]
.
Types can be nested. Procedure names ending with `!' are typed
to return void
. Procedure names ending with `?' are
translated to names with a trailing `_P'.
The Scheme files in the table at
http://people.csail.mit.edu/jaffer/CNS/benchmarks.html#PRNG
have examples of the use of declare-names
.
pragma.java
has no effect, but the strings are written to
filename.java during translation.
Define number-lines? to #t for Java code to be prefixed with commmented line numbers. The default value is #f.
The following procedures are called to translate a file. They should not be called from the file being translated.
If filename.txi is empty after translation, then it is deleted.
declare-name!
) along with the counts of references to each
name pattern type declared.
I am a guest and not a member of the MIT Computer Science and Artificial Intelligence Laboratory. My actions and comments do not reflect in any way on MIT. | ||
Schlep | ||
agj @ alum.mit.edu | Go Figure! |