Brief

This document outlines a parser for D.a.S.T (*D*-ialog *a*-nd *S*-pecial *T*-ags), and the special key words that it uses.

**PLEASE NOTE:** DaST is an incredibly hacky mess of a language, created as a quick, pluggable dialog system, there may be many security holes and the like in this early version of the language.

Basic outline of syntax

DaST files take the form of text files seperated into lines, each being a seperate ‘entry’ in a videogame’s dialog box system.

./img/diagram2.png

Example

[set {aran.name} aran/neutral]This is a test of the dialog system.
I'm <color=red>{aran.name}</color>!
each line is a different text box.
[set aran/happy]I really hope this works!
[ifeq party 4]
The gang's all here!
[else]
I... guess we might need more people
[end if]

Tag Types

DaST has three different tag types, Command, Variable, and Rich Text.

Command

Command tags take the form of square brackets (ASCII 0x5B & 0x5D, “[]”), and are parameterized via the space character (ASCII 0x20, ” “) or with “long” commands the comma (ASCII 0x2C “,”), command tags provide special functionality, branching, and a form of control flow to the dialog system, they provide a form of function call to the main dialog system

Variable

A tacked on variant of python’s str.format(obj) function, and is in effect the exact same syntax, minus the leading dot.

Rich Text

Passed verbatim to unity, and handled as appropriate, syntax is the Rich Text system found in the Unity Documentation; and allows the formatting of text.

Command Keywords

Standard Version

chr
(2, <speaker-text> <faceplate>) Sets the faceplate and speaker text used by the side, assumed to be a directory path with the default extension of png.
if
Includes the dialog up to either an [end] tag, or an [else] tag.
Bare form
(1, <eval-text>) Jumps to else if passed 0, carries on to the next line if passed 1.
ifeq
(2, <value1> <value2>) Checks if the two values passed are equal.
ifne
(2, <value1> <value2>) Checks if the two values passed are not equal.
ifgt
(2, <value1> <value2>) Checks if the first value is greater than the second value. (NB: Values are type-coerced into floats, and are assumed to be such)
iflt
(2, <value1> <value2>) Checks if the first value is lesser than the second value. (NB: Values are type-coerced into floats, and are assumed to be such)
else
(0) Is jumped to if the previous [if*] command returns false.
end
(0) Ends a block statement
jump
(1, <line-in-code>) Jumps to the set line, if the line contains a command tag, it tries to handle it appropriately.
comment
(0) Ignores the entire line.
#
(0) Alias for comment for script users.
rem
(0) Alias for comment for batch and BASIC users. It’s there because it’s there, and easy to implement.

Extended Version

sound
(1, <path>) Sound to be played, assumed to be a directory path with the default extension of ogg unless specified.
call
(1, <method-name>) calls a method from a passed list of objects.
ask
(long, *) Prompts a choice with questions

Parser flow

 +-------------------+
 |      Begin        |
 +-------------------+
           |
           |
           |
           V
 +-------------------+
 | Text is passed    |
 | through python's  |
 | .format()         |
 | operator          |
 +-------------------+
           |
           |
           |
           v
 +--------------------+
 |   Text is split    |
 |   into lines       |
 |                    |
 +--------------------+
           |
           |
           |
           v
+--------------------+
|  "If" Statements   |
|  are serialised w/ |
|  text              |
+--------------------+
           |
           |
           |
           |
           v
 +------------------+
 | loop unless null | <------------+
 | or line "[end]"  |              |
 +------------------+              |
           |                       |
           |                       |
           |                       |
           v                       |
+--------------------+             |
|                    |             |
|  Serialize and     |-------------+
|  return statement  |
|                    |
+--------------------+