Program Structure - mileszim/horatio GitHub Wiki
Title
The first line of every SPL program is the title. Or actually, everything up until the first period is the title, whether it's one line, three lines, or half a line. You're generally free to insert space and newlines wherever you want in the code, but we urge you to please indent tastefully.
The title serves only aesthetic purposes. From the parser's point of view, it's a comment.
Dramatis Personae
The next few lines are a list of all characters in the play. Think of them as variables, capable of holding a signed integer value. You must declare every character you intend to use, or the program won't compile.
A declaration consists of a name, followed by a description of the character (which is ignored by the parser). You can't pick just any name, however; you must use a real Shakespeare character name, such as Romeo, Juliet, or the Ghost (Hamlet's deceased father).
Acts & Scenes
The purpose of acts and scenes is to divide the play into smaller parts. A play consists of one or more acts, each act consists of one or more scenes, and each scene consists of lines (where the characters say something) and enter and exit statements, which cause characters to get on and off the stage.
Acts and scenes are numbered with roman numerals. They begin with the word "Act" or "Scene", then the number, and then a description of what happens in that act or scene. Just as with the title and the character descriptions, these descriptions are ignored by the parser.
Besides being beautiful and descriptive, acts and scenes also serve as labels, which can be jumped to using goto statements. There are no gotos in the Hello World program, however, so we'll talk about that later.
Enter, Exit, Exeunt
To be able to speak their lines, characters must be on stage. The character they address as "you" (or "thou" or any other second-person pronoun) must also be on stage. But if there is yet another character on stage, it's not clear which one is intended. This is frowned upon by the parser.
Enter Enter and Exit5. These directives cause characters to get on and off stage. "Enter" is followed by a list of one or more characters. "Exit" is followed by exactly one character. The plural of Exit is "Exeunt", which is followed by a list of at least two characters - or none, in which case everyone leaves.
An Enter directive given to a character already on stage, or the other way around, will cause a runtime error.