Screet
Screet is an embeddable object-oriented scripting language.
Screet is designed to be embedded in a larger program, providing an
object-orient interpreter to inspect and control aspects of the program.
The interpreter currently compiles to well under 100K of object code on
x86.
Screet can also operate on
Woosh
objects. The screet-woosh program provides a
command-line environment for evaluating Screet expressions on Woosh
objects. It also provides a way to write Woosh methods in Screet.
Object Model and Syntax
All Screet expressions yield strings. However, when performing a
function call, some strings are treated specially: strings representing
numbers are treated as numbers, and strings beginning with certain
special prefixes are treated as objects and error values.
Most expressions will be function calls. The most basic syntax for
function calls looks like object.function(argument-1, argument-2)
. Function calls with no arguments don't need the parentheses --
object.function is the same as object.function()
. The usual suite of C operators is also available (with C's
precedence rules); these are also treated as function calls. There is
also an alternate function call syntax that resembles a CLI:
object function argument-1 argument-2 .
There are also assignment expressions: variable = expression
. The variable is created if it doesn't already exist. There is
only a global scope. If Screet is embedded, the enclosing program may
predefine variables; screet-woosh makes all Woosh objects
available as variables. Variable names may contain hyphens (and are
encouraged to), but not at the beginning or end.
Other expressions are literals -- string literals, numbers,
true , false , and nil
(false and nil are both the empty string).
There are also statements. Currently only if statements
and compound statements ( { expression; expression; } ) are
implemented. Statements are actually expressions too; an if
statement yields the value of the chosen branch, and a compound
statement yields its last expression.
The complete syntax is described in the "syntax.txt" file in the
tarball. But not everything works the way it's supposed to at the
moment.
Embedding Screet
The easiest way is to include ScreetMethodCall.Screetable.cpp in your
project (along the rest of the files from the tarball, except Main.cpp
and WooshContext.cpp), and make the classes to which you want to have
access be subclasses of Screetable, defining screetCall() functions for
them.
You can create a ScreetListener object and call its listen() function to
have it listen on a TCP socket. Do this in a separate thread -- it
doesn't return. Use the screet-to program ("make
screet-to " to build it) to connect to it and have it evaluate
expressions.
See Main.cpp for examples.
Screet and Woosh
Build screet-woosh by doing
"make clean && make screet-woosh ". (You have to make clean
anytime you switch between screet-woosh and other make targets, since
different compiler options are used.) Put screet-woosh
somewhere in your $PATH .
Running screet-woosh with no arguments gives you a command
line at which you can type expressions and see the results. (Like
bash , screet-woosh uses the readline
library to provide editing and history.)
You can also write Woosh methods in Screet. Here's an example:
#!/usr/bin/env screet-woosh
{
if (arg-1 == "Yes")
some-object.some-method();
else
"Sorry, " + arg-1 + " isn't Yes.";
}
Downloading Screet
The Screet tarball is available at
http://www.folta.net/steve/Screet/screet.tgz
.
Contact Info
Send bug reports, etc. to steve@folta.net.
|