Sappho - storytron/swat GitHub Wiki

Sappho (SAF-foh) is the scripting language for Storytron. Originally designed for writers and other storytelling professionals, it has some special features:

  • Making syntax errors that the compiler will not understand is not possible
  • Forgetting to set up things properly or initialize them is not possible
  • Making typos by mistyping commands and operators is not possible since the language is designed around a point-and-click inverse parser
  • You are prompted for the correct arguments to functions and control structures (see strong data typing below)
  • Each script is organized in a top down tree structure, mirroring Sappho stack-based nature
  • Only legal operators are available for use depending on what data is needed at any given moment

Data Typing

Sappho is a strongly typed language. With other strongly typed languages you would have to define your variables up front, indicate their type, and possibly give them an initial value. It might look something like this:

public final class Swat {
    public static enum EditorEnum { NoEditorHasFocus, VerbEditorHasFocus, ActorEditorHasFocus, RelatioshipEditorHasFocus, PropEditorHasFocus, StageEditorHasFocus };
    private static final long serialVersionUID = 1L;

    private static JMenuBar menuBar;
    private static JToolBar toolBar;
    protected Frame myFrame;
    private EditorEnum editorInFocus = EditorEnum.NoEditorHasFocus;

    public ImageIcon iconNew;
    public ImageIcon iconOpen;
    public ImageIcon iconSave;
    ...
}

Sappho does away with all that. Creating verbs, actors, stages, and props is defining your variables. These variables are automatically assigned a type. And type is indicated by the color of the variable in a Sappho script.

Color Type
Bright Red Bright Red Bounded or Unipolar Number
Dark Red Dark Red Regular Number
Blue Blue Actor
Green Green Verb
Black Black Boolean
Magenta Magenta Prop
Orange Orange Stage
Cyan Cyan Event
Blue-Green Blue-Green Trait
Purple Purple Quantifier
Gray Gray Comment

The colors make it easier to tell what is what in a Sappho script. Also, with Sappho you cannot accidentally mix props and actors since the language will not let you put a prop into a slot meant for an actor, or vice versa.

The Sappho scripting language contains about 600 operators. If you are familiar with other programming languages you will notice that the flow control operators provided by other languages, things that allow looping, branching, and subroutines are missing (there are implicit looping operators like CandidateActor and ReactingActor that accomplish the same thing). There is a system called Poison that handles runtime errors so storyworlds will not "crash."

Here is an example of a Sappho script:

make you type this when you define variables.

Note: Being a stack-based language, Sappho structures this line of code as an outline to make constructing the script as error free as possible.