                   REFAL-JAVA PROGRAMMING SYSTEM

Compiler from Refal to Java and run-time library written in Java


Installation
------------

0. Unpack RefalJava.zip file to a new directory ddd

1. Set variable JAVA_HOME to your java (JDK) home directory
   or commands javac, java must work

2. Set variable REFALJ_HOME to the ddd directory

3. Make sure ddd\bin\*.bat files are seen via your PATH
   (ie include ddd into your PATH or copy ddd\bin\*.bat
   files to another directory from your PATH)
   
See ddd\bin\*.bat files for details

Bootstrapping
-------------

in lib compile
	compiles Refal runtime library (package org.refal.j in Java)

in lib compileOpt
	compiles additional classes (generated by JScp)

in compiler Makec.bat
	builds file c.rex in compiler directory 
	(using compiler bin\c.rex running under rasl interpreter ri.exe)

in compiler Makecj.bat
	builds file cj.rex in compiler directory
	(using compiler bin\c.rex running under rasl interpreter ri.exe)

in compiler MakeJcj.bat
	compiles the compiler from Refal to Java and then to class-files 
	into directory compiler\classes 
	(using compiler bin\cj.rex running under rasl interpreter ri.exe)
	Also makes directory compiler\S and copies file MakeJJcj.bat to it

in compiler\S MakeJJcj.bat
	compiles the compiler from Refal to Java and then to class-files 
	into directory .\classes 
	(using java-version of compiler in ..\classes)
	Also makes directory .\S and copies file MakeJJcj.bat to it
	
in compiler\S\S MakeJJcj.bat
	-- " --
	
and so on

in compiler makeJar
	makes rfjc.jar in home directory
	
in compiler clean
	removes all results of bootstrapping
	
in lib makeJar
	makes reflib.jar in home directory. To use it change files rfjava and rfjavac.

in lib clean
	removes compiled classes

Usage
-----

rfcj files
	compiler from Refal-6 to Java (using bin\cj.rex). 
	call rfcj (without parameters) to get more info

rfcjj files
	compiler from Refal-6 to Java (using java version 
	of Refal-Java compiler in %RFJC_CLASSES%, rfjc.jar by default). 
	call rfcjj (without parameters) to get more info

rfjavac resulting-java-file(s)
	compiling further to java byte-code

rfjava  module-with-Main arguments
	Start execution from <Main e.arguments>,
	where each term in e.arguments is a separate
	command line argument as a word
	
rfcjavac file
	compile .ref file to .class file, 
	using switch /D - debug mode
	(within default package only)
	
rfcjava file arguments
	compile-and-run a single ref file
	using switch /D - debug mode
	(within default package only)

rfc files
	old Refal-6 compiler to RASL
	(see bin\Ref6Help\readme.txt for details)


Tracing
-------

Enable trace mode by compiler option /D. Then activate

	<TRACE F1 F2 ...>,

For example, add following lines to your .ref file:

	$exec TRACE F1 F2 ;

As result, functions F1, F2 will be traced 
(regardles of where they are defined)
At the function's start its argument is printed, 
at the function's end its result is printed.
Use numbers printed in front of each line 
to relate result with the argument.


Running in interactive mode
__________________________

rfrun module1+module2+...+*Fun arg1 arg2 ....
	loads specified modules and calls <Fun> or <FUN> (trying in this order).
	Use function Fun=ask to start dialogue mode. In dialogue mode after prompt #>
	enter function name Fun and argument expression as in Refal. Term
	<Fun expression> will be activated. The result of evaluation the term will be printed.
	
	Note: module maybe refal-6 .rex file not containing function definitions. It may
	contain arbitrary result expressions (without variables) which are evaluated immediately.
	Results are lost.

	^Z terminates (or exit) the session
	
rfcrun file Fun arguments...
	compile-and-run .ref file 
	starting from function Fun
	with arguments accessible as <ARG 1>, <ARG 2> etc.