Index
OzServer
Socket
CustomCompiler
This is an application which serves as a 'headless' OPI: its starts a full Oz compiler and the compiler awaits arbitrary Oz code (even compiler directives) send via a socket. This allows, for example, another application (e.g. another language such as Lisp, C, ..) to start a full Oz evaluator/compiler and to execute arbitrary Oz code from within that other application. The code is executed concurrently, i.e. without waiting for it to terminate before proceeding to the next fed input.
On its initialisation, the full environment (comparable to the OPI) is loaded to the compiler and it is fed an OZRC file according conventions (cf. oz/doc/opi/node4.html). As interface, the compiler panel GUI is opened. To quit the compiler, quit this application by C-c (closing the panel is not sufficient) or send the OzServer directive quit (see below). When compared with the OPI, the compiler panel (messages panel) serves as Oz Compiler buffer and the standard out of the shell in which the OzServer was started serves as Oz Emulator buffer.


USAGE

OzServer [OPTIONS]


OPTIONS

--port integer Portnumber of socket, defaults to 50000

--file file Feed given Oz source file at initialisation.

--resultFormat symbol An atom specifying the syntax of results output back to the client. Presently, supported values are oz (the default), lisp, and lispWithStrings.
oz: outputs textual representation of the Oz values, terminated by a newline (to distinguish multiple results).
lisp: outputs literal Oz values transformed into Lisp syntax. Transformation to lisp values works for a booleans, numbers, atoms, records/tuples and lists (possibly nested). NB: Strings are not supported in this Lisp output syntax (they are output as integer lists). Other values (e.g. functions, classes) raise an exception.
lispWithStrings: like lisp, but integers between 0-255 are output as characters and lists of integers between 0-255 as strings.
NB: Additional output formats can be specified by extending the procedure TransformResult in /source/Compiler.oz.

--size integer Maximum number of bytes read at once via the socket, defaults to 1024


FORMAT OF THE CODE FEED

["%!"<DIRECTIVE>\n]<CODE>

The Oz compiler can be fed statements by simply sending the code (as a string) via the socket. Alternatively, OzServer supports a few options which are always signalled by the two characters %! at the beginning of the fed (inspired by the UNIX shell #! notation), followed by some directive and a new line before the actual code. Supported directives are

statement The code fed to the compiler is a statement (this is the same as no directive).

expression The code fed to the compiler is an expression and its result is output via the socket.

file The 'code' fed is a path to the file to feed to the compiler.

browse The code fed to the compiler is an expression and its result is presented via the Oz browser.

inspect The code fed to the compiler is an expression and its result is presented via the Oz inspector.

quit Quits the OzServer with return status 0.


NB: Instead of sending very long code strings via the socket, consider writing the code to a file and let the compiler read the file.

NB: As arbitrary code can be executed by a client, this program poses a severe security thread! (e.g., you better don't run this program with root priviliges on a machine with network access, just in case ..).

NB: see TODO list in source for missing/planned features.


Functor

Import

End