-
Notifications
You must be signed in to change notification settings - Fork 9
Interacting with an Interpreter
It is possible to interact with the Kawa interpreter embedded in the SchemeScript plugin. Using this interpreter, one can script Eclipse in Scheme. For example, most of the functionality in version 1.0.0 has been developed interactively using this interpreter.
When an error occurs in the interpreted code, the stack trace can be display in the Kawa Stacktrace View:
The Kawa interpreter can also be used to test custom SWT/JFace controls developed in Kawa Scheme.
To do this, call the add-scratchpad-view
function with two parameters:
a symbol for identifying the view, and a function of one argument that will be called
to create the control in the parent control passed in argument.
The file examples/circles.scm
that can be found in the plugin distribution
is an example of such a control created in Scheme. Here is the result of loading
this file:
Many Scheme interpreters can be started in server mode, waiting for another process to connect on a specific TCP/IP port number. The remote interpreter interface allows SchemeScript to communicate with such interpreters.
The SchemeScript remote interpreter interface is SISCweb ready, i.e. it will connect to port 5156 on localhost by default. This can be changed using the preference page.
SchemeScript provides a minimal interface external to Scheme interpreters.
To configure a Scheme interpreter, open the External Interpreter preference page.
When an error occurs in the interpreter, SchemeScript can turn the location of the error into an hyperlink (given that it is appropriately configured). Here is the result of an interaction with the MzScheme interpreter:
To launch the interpreter from the Scheme perspective, select the interpreter using the "Scheme/Select Interpreter" menu item, and then select the "Scheme/Start Interpreter" menu item or click on the "Start Interpreter" toolbar button. The interpreter will be accessible from the Console View:
In this example, an external Kawa interpreter is run.
S-expressions can be sent directly to the interpreter for evaluation using the Eval Expression and Eval toplevel Expression commands from the editor ( à la Emacs). See Editing.
For example, suppose that the cursor is located after the closing parenthesis in:
define
form)
to the interpreter. Also, pressing Ctrl-Shift-Enter will send to the interpreter
the top-level expression that encloses the cursor position.
The whole editor content can be sent to the interpreter using the Load File in Interpreter command, which is bound to the Ctrl-Shift-L key sequence by default.
Note: This applies only to external interpreters.
If the external interpreter supports interruption using kill -2, follow these steps before starting the interpreter:
- Check the "Interpreter saves PID" check box in the "Scheme/External Interpreter" preference page.
- Pass the name of the file where the PID of the Scheme process must be stored to the Scheme interpreter
using the
{pidfile}
variable on the command-line arguments. The Scheme process must then save its PID in the given file. (Most Scheme system allow the evaluation of command-line arguments).
To interrupt an evaluation, simply select the "Scheme/Interrupt Evaluation" menu item or press ALT-F9 in the Scheme perspective. You can also click on the corresponding toolbar button.
Fast Eval keys are configurable commands that send predefined expressions to the interpreter. These expressions are configured in the Fast Eval preference page.
For example, suppose that Fast Eval Key #0 is set to (test)
. Every time
the Fast Eval 0 command is run (by pressing Alt-K 0 by default), the string
(test)
is sent to the interpreter.