|
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 batch
files has been created provided in the bin sub directory of the
FESI installation. It can be edited to adapt the classpath or other
parameters. Example:
java -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
@module 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.
Batch mode
If started in batch mode (without the options -i), 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.
- If the option -R className is specified, then the
specified
regular expression extension is loaded (otherwise FESI attempts to use
the
JDK text.util pacakge, the ORO pacakge or the GNU package, in that
order.
- If the option -e className is specified, the specified
class
is loaded as an extension.
- If the option -f filename is specified, then the file is
loaded (without searching in the path).
- If the option -m modulename is specified, then the jar
entry
or file is loaded, searching in the path.
- If the option -o filename is specified, the output is
redirected to the specified file.
- If the option -w is specified, error output is displayed
via
an AWT popup window, and BasicIOw
is loaded instead of BasicIO ( for use with jrew and AWT
based applications).
- If the option -s is specified, error output is displayed
via
an Swing popup window, and BasicIOs is
loaded instead of BasicIO ( for use with jrew and Swing based
applications).
- If the option -i is specified, an interactive
read-eval-print
loop is started (rather than a batch mode interpretation).
- If the option -v display the version of FESI and of the
environment
even if not in interactive mode..
- If the option -h filename is specified, the
corresponding html file will be expanded (as with the @expand
command). It is not
looked in the path.
- If the option -T filename is specified, the test file is
processed (used for validation). It is not looked in the path.
- If the option -D is specified, all tracing flags are
turned
on.
- If the option -A ... is specified, all arguments after -A
are passed in the args[] array of the evaluated program)
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:
fesi preload.es -- postload.es -o result.lis
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:
| @exit |
Exit the interpreter |
| @reset |
Reset the interpreter to a null environment (forgetting all
loaded files
too) |
| @version |
Display version of interpreter
|
| @detail |
Return detail of last evaluation |
| @extensions |
List loaded extensions (can be loaded with loadExtension(class)
) |
@module
|
Load the module in the directories and jar/zip
files of the property FESI.path or (if the property is not defined) in
the
classpath (possibly adding the extension ".es", ".esw' or ".js").
|
| @load |
Load the files (possibly adding the extension ".es", ".esw'
or ".js"). |
| @pwd |
Print current user directory |
| @expand |
Expand an HTML file between <script> and </script>
lines, display on standard output |
| @help |
Display an short list of the allowed commands |
| @about |
Display information on FESI |
| @detail |
List the details of the last evaluation |
| @list |
List the enumerated properties of the object (default to
the global properties) |
| @listall |
List all properties on an object (defaults to the global
object) |
| @describe |
Describe the detail characteristcis of an object, including
java reflection data. |
| @memory |
List the total and available memory (as reported by the
Java runtime). |
| @clear |
Clear the console window (but not the interpreter content).
Usefull when reaching the limits of the console text area control. |
| @path |
Display the current load path. |
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
| Copyright ©
Jean-Marc Lugrin 1998-2003 - Under LGPL license |
Last update: 26 August 2003 |