Mundorum

gnō-

gnō Syntax

This document describes the syntax of the gnō narrative language, version 1.1: every structure an author can write in a .gno file, what it is for, how it is written, and examples. What the Player does with each structure (screens, the stage, graphic play) is described in the README; the files that hold the scenarios’ graphic design, in the scenario SVG reference; what changed from one version of the language to the next, in the versions journal.

A .gno file is Markdown. gnō adds a few kinds of line to it (scene headings, entity lines, dialogs, pauses and diverts) and leaves every other line to Markdown.

Notation

Each structure is described by a small grammar written in a minimal subset of Extended BNF:

Notation Meaning
a = … the rule that defines a
"…" written exactly as shown
a b a followed by b
a \| b either a or b
[ a ] a is optional
{ a } a repeated zero or more times
<…> a description in words, where a rule would say less than the words do

Spaces between the items of a rule may be written or left out. A quoted space, " ", means at least one space is required at that point. Rules that build a single word (such as entity-id) allow no spaces inside.

Each rule comes with a concrete example on the line below it, marked ▸:

choice = "*" " " label arrow target
         ▸ * Examine the patient -> Examination Room

Each structure is then shown in use, in examples written as they would appear in a .gno file.

Narrative

A narrative is a complete interactive story, written in a single .gno file. It is a sequence of scenes. Each scene takes place in a scenario (a place or setting), and several scenes can share the same scenario.

narrative = { preamble-line } scene { scene }
            ▸ # Emergency Room: Hospital (*)
              …
              # Examination Room: Hospital
              …
scene     = scene-heading { scene-line }
            ▸ # Emergency Room: Hospital (*)
              The waiting room is crowded.
              * Examine the patient -> Examination Room

Lines before the first scene heading (the preamble) belong to no scene. The Player never shows them, so they can hold notes for the author.

Draft of the zombie emergency case. Notes for the author only.

# Emergency Room: Hospital (*)

The waiting room is crowded and noisy.

* Examine the patient -> Examination Room

# Examination Room: Hospital (**)

The patient lies down, pale and silent.

Scene

Scene heading

A scene is the basic unit of a narrative: one moment of the story, presented to the reader on its own, one scene at a time. A scene can stand for a place, a focus inside a place, or a state of the story. The scene heading starts a scene and gives its title and its scenario. The scene runs until the next scene heading.

scene-heading = level " " title ":" scenario [ marker ]
                ▸ # Emergency Room: Hospital
level         = "#" | "##" | "###" | "####" | "#####" | "######"
                ▸ ##
title         = <text without ":">
                ▸ Emergency Room
scenario      = <text>
                ▸ Hospital
# Emergency Room: Hospital

## Zombie Treatment: Hospital

# Waiting Room: Hospital

### Symptoms

The first three lines start scenes, two of them in the same scenario, Hospital. ### Symptoms has no colon: it is a heading inside the Waiting Room scene.

Start and end markers

The markers tell the Player where the narrative begins and where it ends. They are written in parentheses at the end of a scene heading, after the scenario. Being symbols rather than words, they read the same whatever the narrative’s language.

marker = "(*)" | "(**)"
         ▸ (*)
# Emergency Room: Hospital (*)

# Zombie Treatment: Hospital (**)

Scene content

scene-line = choice | pause | dialog | entity-divert | entity-options
           | entity-line | exit | text-line | <blank line>
             ▸ -- @Lucinda: Hey doctor, you must come here.

Each kind of line is described below. How the editor decides which kind a line is, when it could be more than one, is summed up in How a line is read.

Text

Text is everything the reader reads outside dialogs: the description of the scene, the narration of what happens. It is written in Markdown (GitHub-flavored): paragraphs, emphasis, lists, links, images, block quotes and so on. Entities mentioned in the text are inline mentions.

text-line = <a Markdown line that is no other gnō structure>
            ▸ The patient is a *man*, 55 years old, rather fat.

Blank lines separate paragraphs, as in Markdown, and also end a dialog’s text (see Dialog).

# Emergency Room: Hospital (*)

The waiting room is crowded and noisy. In a corner, a man,
55 years old, rather fat, holds his left arm.

> The night shift has been quiet. Until now.

Pause

A pause splits a scene into beats. The Player shows a scene one beat at a time: it stops at each pause and waits for the reader to continue. Each new beat replaces the previous one on screen.

pause = "--"
        ▸ --
The waiting room is crowded and noisy.

--

A nurse runs toward you, holding a chart.

The reader first sees the waiting room, continues, and then sees the nurse.

Entities

Entities are the characters, objects or other elements present in a scene. They are written with an @ before their identifier, in three forms: alone on a line (standalone entity), at the start of a dialog, or inside text (inline mention). An entity is on stage from the moment it is first mentioned, in any form, until it exits or the scene ends.

Entity reference

An entity reference names one entity, or a group of entities acting together.

entity    = entity-id { "+" entity-id }
            ▸ @Lucinda
entity-id = "@" id-char { id-char }
            ▸ @Dr_Lima
id-char   = <letter> | <digit> | "_" | "'" | "-"
            ▸ é

Group

A group is two or more entities acting together, such as two nurses standing side by side or speaking in unison. In graphic play, a group can have images of its own.

group = entity-id "+" entity-id { "+" entity-id }
        ▸ @Lucinda + @Jacinto
@Lucinda + @Jacinto right ready

-- @Lucinda + @Jacinto: Ready, doctor!

The @Lucinda + @Jacinto lift the patient onto the bed.

Standalone entity

A standalone entity line brings an entity on stage, or changes its state, without saying anything. The state describes the entity at that point: its position, its mood, its posture. In graphic play, the state words choose the entity’s image and the anchor it stands at.

entity-line = entity { " " state-word }
              ▸ @Lucinda right concerned
state-word  = <a word without ":" or "@">
              ▸ concerned
@Lucinda

@Lucinda left concerned

@patient right pale sweating

Exit

An exit takes an entity off stage, from that point of the scene on.

exit = entity " " "=>"
       ▸ @Lucinda =>
-- @Lucinda: I will get the lab results.

@Lucinda =>

Inline mention

An inline mention refers to an entity inside the text. It brings the entity on stage, if it isn’t already, without changing its state.

mention-line = { <text> } entity { <text> | entity }
               ▸ Nurse @Lucinda hands the chart to @Dr_Lima.
Nurse @Lucinda checks the pulse of the @patient, then looks at @Dr_Lima.

Dialog

A dialog is text spoken by an entity, or by a group speaking in unison. It can also set the speaker’s state, as a standalone entity line does.

dialog      = "--" entity { state-word } ":" [ <text> ] { speech-line }
              ▸ -- @Lucinda left concerned: Hey doctor, you must come here.
speech-line = <a line that is not blank and not a dialog>
              ▸ His skin is getting greener by the minute.
-- @Lucinda left concerned: Hey doctor, you must come here.
-- @patient right pale: I... I don't feel well.

-- @Lucinda:
He arrived ten minutes ago.
His skin is getting *greener* by the minute.

-- @Lucinda + @Jacinto: Ready, doctor!

The first two dialogs form a dialog set and share one pause. The third one spans two lines and is shown as one paragraph.

Diverts

Diverts are transitions from the current scene to another. They are of two kinds:

All are written with an arrow followed by the target scene.

Arrows

The arrow says how the target scene is presented.

arrow  = "->" | "~>"
         ▸ ~>
target = <the title of a scene>
         ▸ Examination Room

Choice

A choice is an option offered to the reader: a label and the scene it leads to.

choice = "*" " " label arrow target
         ▸ * Examine the patient -> Examination Room
label  = <text without an arrow>
         ▸ Examine the patient
* Examine the patient -> Examination Room
* Call Dr. Lima -> Doctors' Lounge
* Read the triage notes ~> Triage Notes

The third choice opens Triage Notes as a subscene over the current scene.

Entity divert

An entity divert attaches a divert to an entity. While the entity is on stage, the reader can click it to take the divert, at any point of the scene rather than only at its end. The line also brings the entity on stage, as a standalone entity line does, and can give it a state.

entity-divert = entity { " " state-word } " " arrow target
                ▸ @xray_film left ~> X-Ray
@xray_film left ~> X-Ray

@door -> Corridor

Entity options

Entity options are several diverts offered by an entity: choices written below a standalone entity line, indented. While the entity is on stage, at any point of the scene, the reader opens its options, by clicking the entity or by passing the pointer over it as the narrative’s presentation says (Presentation → Player), and picks one.

entity-options = entity-line option { option }
                 ▸ @Lucinda left concerned
                     * Follow Lucinda => Examination Room
option         = indent "*" " " label option-arrow target
                 ▸   * Ask for the chart ~> Triage Notes
indent         = "  " { " " } | <a tab>
                 ▸ (two spaces)
option-arrow   = arrow | "=>"
                 ▸ =>
@Lucinda left concerned
  * Follow Lucinda => Examination Room
  * Ask for the chart ~> Triage Notes

@door
  * Open it -> Corridor
  * Knock -> Waiting Room

The reader can follow Lucinda, which takes her to Examination Room, or open the chart over the scene. A later @door block would replace the door’s two options.

How a line is read

A line could sometimes fit more than one structure. The editor reads each line of a scene as the first of these that fits:

# The line is Read as
1 a heading (# to ######) with a colon scene heading
2 indented, then *, a space, a label, an arrow (or =>) and a target, right after a standalone entity line or one of its options entity option
3 *, a space, a label, an arrow and a target choice
4 blank end of a dialog’s speech; paragraph break
5 only -- pause
6 -- followed by an entity dialog, with the speech lines after it
7 an entity, state words, a space, an arrow and a target entity divert
8 an entity followed by => exit
9 an entity followed only by words without : or @ standalone entity, with the option lines after it
10 anything else text, with its @ entities as inline mentions (not on lines starting with *)

A line of a dialog’s speech is read as speech, never as an option, even when it is indented and has an arrow.

Grammar at a glance

narrative     = { preamble-line } scene { scene }
scene         = scene-heading { scene-line }

scene-heading = level " " title ":" scenario [ marker ]
level         = "#" | "##" | "###" | "####" | "#####" | "######"
title         = <text without ":">
scenario      = <text>
marker        = "(*)" | "(**)"

scene-line    = choice | pause | dialog | entity-divert | entity-options
              | entity-line | exit | text-line | <blank line>

text-line     = <a Markdown line that is no other gnō structure>
pause         = "--"

entity        = entity-id { "+" entity-id }
group         = entity-id "+" entity-id { "+" entity-id }
entity-id     = "@" id-char { id-char }
id-char       = <letter> | <digit> | "_" | "'" | "-"

entity-line   = entity { " " state-word }
state-word    = <a word without ":" or "@">
exit          = entity " " "=>"
mention-line  = { <text> } entity { <text> | entity }
dialog        = "--" entity { state-word } ":" [ <text> ] { speech-line }
speech-line   = <a line that is not blank and not a dialog>

arrow         = "->" | "~>"
target        = <the title of a scene>
choice        = "*" " " label arrow target
label         = <text without an arrow>
entity-divert = entity { " " state-word } " " arrow target
entity-options = entity-line option { option }
option        = indent "*" " " label option-arrow target
indent        = "  " { " " } | <a tab>
option-arrow  = arrow | "=>"
Symbol Where Meaning
# … : heading scene title and scenario
(*) / (**) end of a scene heading start scene / end scene
-- alone on a line pause
-- before an entity dialog
@ before an identifier entity
+ between entities group
: after a dialog’s entity and state start of the speech
=> after an entity exit
-> before a target divert: go to the scene
~> before a target divert: open the scene as a subscene
=> before a target, in an entity option divert: go to the scene, taking the entity along
* start of a line with an arrow choice
* indented, under a standalone entity line entity option

Complete example

Draft of the zombie emergency case. Notes for the author only.

# Emergency Room: Hospital (*)

The waiting room is crowded and noisy. In a corner, a man,
55 years old, rather fat, holds his left arm.

--

@Lucinda left concerned
  * Follow Lucinda => Examination Room
  * Ask Lucinda for the chart ~> Triage Notes

-- @Lucinda left concerned: Hey doctor, you must come here.
-- @patient right pale: I... I don't feel well.

-- @Lucinda:
He arrived ten minutes ago.
His skin is getting *greener* by the minute.

@xray_film middle ~> X-Ray

* Examine the patient -> Examination Room
* Read the triage notes ~> Triage Notes

# Triage Notes: Hospital

*Bitten on the left arm at 2 a.m. Fever. Asks for brains.*

# X-Ray: Radiology

The film shows a perfectly normal chest.

# Examination Room: Hospital

Nurse @Lucinda helps the @patient onto the bed.

@patient middle lying

@Lucinda + @Jacinto right ready

-- @Lucinda + @Jacinto: Ready, doctor!

@Lucinda + @Jacinto =>

* Prescribe the zombie treatment -> Zombie Treatment

# Zombie Treatment: Hospital (**)

The color slowly comes back to the face of the @patient.

-- @patient middle relieved: Thank you, doctor. I no longer want brains.