Free EcmaScript Interpreter.  
A JavaScript interpreter written in Java.
 
 
The interactive interpreter 

Calling the interpreter

The interpreter can run in batch mode and in interactive mode. A set of batch files are provided in the bin sub directory of the FESI installation. They must be edited to adapt the classpath. Example:
 
jre -DFESI.path=.;fesilib.jar -cp c:\program files\FESI\fesi.jar FESI.Interpreter.Interpret -f %1

The source files with extension "js", "es" and "esw" are recognized. As "js" is often used by Netscape or the Internet Explorer, this allows to bind "es" and "esw" to FESI.
The property FESI.path list the paths where the code is looked for load from the command line, by the load function (of BasicIO) and by the @load command.If it is absent, the java CLASSPATH is used instead. To obtain the same behaviour as before version 0.9-9, use "-DFESI.path=." and use the option -f followed by a file name on the command line.

The command file FESIIS should be used to have the editing environment (a file may be dropped on the batch icon or the extension may be associated with this batch file). The properties of the batch file may be set to exit automatically at end and run (the batch file) iconified. The batch file used for the windowing environments (FESIW, FESIS, FESIIW, FESIIS)  use jrew. Therefore any error message due to a bad path or missing library is not seen. You may replace jrew by jre for debugging purpose.

Batch mode

When batch mode (the default), the interpreter reads and interprets the files specified in the command line and output the result to the standard output stream (with error to the standard error stream). If no file is specified on the command line, the standard input is read. The standard input can be specified by the "" (two dashes) on the command line too. In both cases the standard input is read in batch mode (that is until an EOF is encountered, then interpreted). Any error will terminate the evaluation.
  The option letters 'f', 'o', 'h', 'T' and 'A' must be the last ones of an option string (-wo is ok, -ow is not ok) because they must be immediately followed by their arguments.

Examples:

The above command will process preload.es, the standard input file and the postload.es, writing the result to result.lis. It could be attached to a specific extension under Windows.

The test mode (option -T)  implements the special FESI command

@test nameOfTest
All the code which follows the @test command, until the next @test command or end of file, is interpreted in a special test mode. In that mode, the name of the @test is printed and the code is execute.  Any error causes a message to be printed and the interpretation to skip to the next @test. If no error is detected, the result of the last statement is evaluated. If it is true the test is considered successful, otherwise an error message is printed.

Interactive mode

In interactive mode (option -i) first the file specified via -f or the -m are executed. Then files specified in the command line are loaded in the editor (Swing version only). Finally the system enter an interactive read-eval-print loop. Each statement is evaluated immediately when entered, and errors are not fatal. If a statement is incomplete, the interpreter requires more data (just enter ";" to force the end of a statement).

All batch mode options are allowed too, so it is possible to preload an environment before entering the interactive mode.

In addition the user can type the following commands:

A couple of other commands are used to debug the interpreter or the access to the Java system, they are listed with the @help command. The commands can be abreviated to the first unambiguous prefix.
The interactive mode is useful to test short commands, or to load a file and then test its definitions.

If both the -i and -w options are given, an interactive window is used. Its implementation is very limited, and this is for use in operating systems with an even poorer native console interface only.
 


Return to the main page

Last update: 10 September 1998