Documentation
¶
Overview ¶
Package yack reads and runs yack dialogs.
The EBNF grammar for yack files:
SourceFile = { Line } . Line = [ (LabelTag | ConditionalStatement) ] [ comment ] newline . LabelTag = ":" label . ConditionalStatement = Statement { Condition } . Condition = "[" ("once" | "showonce" | "onceever" | "showonceever" | "temponce" | actor_name | Code) "]" . Statement = SayStmt | GotoStmt | ExecuteStmt | ChoiceStmt | ShutUpStmt | PauseStmt | WaitForStmt | WaitWhileStmt | ParrotStmt | DialogStmt | OverrideStmt | AllowObjectsStmt | LimitStmt . SayStmt = actor_name ":" string_lit [ GotoStmt ] . GotoStmt = "->" label . ExecuteStmt = "!" Code . ChoiceStmt = int_lit (string_lit | ("$" Code)) GotoStmt . ShutUpStmt = "shutup" . PauseStmt = "pause" float_lit . WaitForStmt = "waitfor" [ actor_name ] . WaitWhileStmt = "waitwhile" Code . ParrotStmt = "parrot" bool_lit . DialogStmt = "dialog" actor_name . OverrideStmt = "override" label . AllowObjectsStmt = "allowobjects" bool_lit . LimitStmt = "limit" int_lit . Code = /* Scripting language expression, e.g. Squirrel */ . comment = ";" { unicode_char } . actor_name = unicode_letter { unicode_letter | unicode_digit } . label = letter_uscore { letter_uscore | unicode_digit } . letter_uscore = unicode_letter | "_" . bool_lit = "yes" | "YES" | "no" | "NO" . int_lit = decimal_digits . float_lit = decimal_digits | decimal_digits "." [ decimal_digits ] | "." decimal_digits . decimal_digits = { decimal_digit } . decimal_digit = "0" … "9" . string_lit = `"` { unicode_value } `"` . unicode_value = unicode_char | escaped_char . escaped_char = `\` ( "n" | `\` | `"` ) . newline = /* the Unicode code point U+000A */ . unicode_char = /* an arbitrary Unicode code point except newline */ . unicode_letter = /* a Unicode code point classified as "Letter" */ . unicode_digit = /* a Unicode code point classified as "Number, decimal digit" */ .
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChoiceOption ¶ added in v0.3.0
type ChoiceOption struct { Text string // contains filtered or unexported fields }
type Choices ¶ added in v0.3.0
type Choices struct { Actor string Options []*ChoiceOption // contains filtered or unexported fields }
type ConditionalStatement ¶
A ConditionalStatement is a statement guarded by zero or more conditions.
func (ConditionalStatement) String ¶
func (c ConditionalStatement) String() string
String formats the conditional statement in yack syntax, e.g. "statement [condition1] [condition2] [condition3]"
type Dialog ¶
type Dialog struct { Statements []ConditionalStatement Labels map[string]int }
Dialog is a parsed yack dialog. It consists of a sequence of statements, each one guarded by zero or more conditions, and a label index. Each label points via index to a statement in the statements slice.
func Load ¶
Load reads and parses a dialog from a yack file. File IO or syntax errors are returned as error.
type Runner ¶ added in v0.3.0
type Runner struct {
// contains filtered or unexported fields
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.