Expression
Expression Types.
Each of these represents an expression encountered in a statement
Expression
Static Members
Base class for all expressions
new Base()
Instance Members
location
Returns
Location
:
the location of this expression in the original file
Represents a en expression that is a variable
new Variable()
Extends
Expression.Base
Instance Members
name
Returns
string
:
Variable name
Represents a en expression that is represents a function call
new Function()
Extends
Expression.Base
Instance Members
name
Returns
string
:
function name
args
Returns
Array<Expression.Base>
:
expressions that are the arguments to this function
▸
new AddAssignOperator()
Add Assignment operator ("$variable += {expr}") - assign the result of $variable + {expr} to $variable
new AddAssignOperator()
Extends
Expression.AssignmentOperator
Assignment operator ("$variable = {expr}") - assign the result of {expr} to $variable
new AssignOperator()
Extends
Expression.AssignmentOperator
▸
new AssignmentOperator()
Base class for operator expressions that assign values to variables
new AssignmentOperator()
Extends
Expression.Base
Instance Members
variable
Returns
Expression.Variable
:
the variable the result of the expression will be assigned to
expression
Returns
Expression.Variable
:
the expression to assign to the variable
▸
new DivideAssignOperator()
Divide Assignment operator ("$variable /= {expr}") - assign the result of $variable divided by {expr} to $variable
new DivideAssignOperator()
Extends
Expression.AssignmentOperator
▸
new ModulusAssignOperator()
Modulus Assignment operator ("$variable %= {expr}") - assign the result of {expr} to $variable
new ModulusAssignOperator()
Extends
Expression.AssignmentOperator
▸
new MultiplyAssignOperator()
Assignment operator ("$variable = {expr}") - assign the result of {expr} to $variable
new MultiplyAssignOperator()
Extends
Expression.AssignmentOperator
▸
new SubtractAssignOperator()
Assignment operator ("$variable = {expr}") - assign the result of {expr} to $variable
new SubtractAssignOperator()
Extends
Expression.AssignmentOperator
▸
new LeftRightOperator()
Base class for operator expressions with left and right operands
new LeftRightOperator()
Extends
Expression.Base
Instance Members
left
Returns
Expression.Base
:
the left expression for this operator
right
Returns
Expression.Base
:
the right expression for this operator
Base class for operator expressions with only right operands
new RightOperator()
Extends
Expression.Base
Instance Members
expression
Returns
Expression.Base
:
the expression this operator is performed on
And operator ("a && b") - result when executed will be a boolean
new AndOperator()
Extends
Expression.LeftRightOperator
Equality operator ("a == b") - result when executed will be a boolean
new EqualityOperator()
Extends
Expression.LeftRightOperator
▸
new GreaterThanOperator()
Greater than operator ("a > b") - result when executed will be a boolean
new GreaterThanOperator()
Extends
Expression.LeftRightOperator
▸
new GreaterThanOrEqualOperator()
Greater than or equal operator ("a >= b") - result when executed will be a boolean
new GreaterThanOrEqualOperator()
Extends
Expression.LeftRightOperator
Less than operator ("a < b") - result when executed will be a boolean
new LessThanOperator()
Extends
Expression.LeftRightOperator
▸
new LessThanOrEqualOperator()
Less than or equal operator ("a <= b") - result when executed will be a boolean
new LessThanOrEqualOperator()
Extends
Expression.LeftRightOperator
Not operator ("!a") - result when executed will be a boolean
new NotOperator()
Extends
Expression.RightOperator
▸
new NotEqualityOperator()
Not/Inverse equality operator ("a != b") - result when executed will be a boolean
new NotEqualityOperator()
Extends
Expression.LeftRightOperator
Or operator ("a || b") - result when executed will be a boolean
new OrOperator()
Extends
Expression.LeftRightOperator
Exclusive Or operator - result when executed will be a boolean
new XorOperator()
Extends
Expression.LeftRightOperator
Add operator ("a + b")
new AddOperator()
Extends
Expression.LeftRightOperator
Divide operator ("a / b")
new DivideOperator()
Extends
Expression.LeftRightOperator
Modulus operator ("a % b") (returns the remainder of a divide operation)
new ModulusOperator()
Extends
Expression.LeftRightOperator
Multiply operator ("a * b")
new MultiplyOperator()
Extends
Expression.LeftRightOperator
Not operator ("-1") - result when executed will be the negative value of the expression
new NegativeOperator()
Extends
Expression.RightOperator
Subtract operator ("a - b")
new SubtractOperator()
Extends
Expression.LeftRightOperator
a static boolean value
new BooleanValue()
Extends
Expression.Base
Instance Members
value
Returns
boolean
:
boolean value
a static float value
new FloatValue()
Extends
Expression.Base
Instance Members
value
Returns
number
:
float value
a static integer value
new IntegerValue()
Extends
Expression.Base
Instance Members
value
Returns
number
:
integer value
a null value
new NullValue()
Extends
Expression.Base
A static string value
new StringValue()
Extends
Expression.Base
Instance Members
value
Returns
string
:
string value
ParserConfig
parser configuration
new ParserConfig()
Static Members
Should this parser only preprocess files and then stop.
Default is false
preprocessOnly
Type:
boolean
Should this parser output preprocessed files with visible option brackets
Default is false
preprocessDebug
Type:
boolean
Should the parser output a dialog segment for each line.
If this is false a blank line will split dialogue segments
Default is true
dialogSegmentPerLine
Type:
boolean
characterSupport
Should the parser interpret a dialog segment text fragment ending with ":"
as a character name.
e.g. "character name: i speak the thing"
characterSupport
Parser
Instances of this class are used to parse one or more yarn documents
Parameters
Instance Members
▸
parse(yarnString, bodyOnly, fileID)
Parse more yarn text input and add it to the nodes already present.
If the yarn is body only, the node will be called bodyParsed
and any previous contents will be overwritten
Parameters
yarnString (string)
the yarn string to process. Can contain body only or header and body.
bodyOnly (boolean)
if this yarnString is only body.
fileID (string)
an identifer for the source of the yarnString that is being passed in.
Returns
boolean
:
if there was an additional parsing error.
Get the last output from the preprocessor (will be the last parse call)
preprocessedData
Returns
string
:
the preprocessed data
Get the names of the nodes parsed so far
nodeNames
Returns
Array<string>
:
the node names
Get a node with this name
Parameters
name (string)
the name of the node to get
Returns
Node
:
the node with this name (or null)
Get a node tagged with this name
Parameters
tag (string)
the name of the tag to get nodes for
Returns
Object<string, Node>
:
The nodes in this tag (or null if tag doesn't exist)
Get the list of functions
functionNames
Returns
Array<string>
:
the list of function names.
Get the list of variables
variableNames
Returns
Array<string>
:
the list of function names.
Reset this parser, removing all parsed information
reset()
Node
Represents a yarn node
new Node()
Properties
name (string)
: The title of this node. Should be unique.
Instance Members
▸
actualizeLinks(namedNodes)
turn the text linked names into actual node links.
must be run before outgoingLinks or incomingLinks will be valid
Parameters
namedNodes (Object<string, Node>)
a Key, Value store of the node names and the actual nodes to link to.
attributes
Returns
Object
:
the attributes for this node. A dictionary of key value pairs.
statements
Returns
Array<Statement.Base>
:
the statements in this node
location
Returns
Location
:
the location of this node in the original file
hasStatements
Returns
boolean
:
does this node have any statements?
outgoingLinks
Returns
Object<string, Node>
:
a key-value map of outgoing link names. Values are null if the nodes don't exists and a Node if they do
incomingLinks
Returns
Object<string, Node>
:
a key-value map of incoming link names and the Nodes that link to this one
Location
Instances of this class detail where in a file statements, warnings or errors are.
Line and column information should be integers.
If start and end are null, this location is for a given file.
new Location()
Properties
fileID (string)
: The ID of the file this location pertains to.
nodeName (string)
: The name of the node this location pertains to (if available)
start (object)
: The start of this location.
end (object)
: The start of this location.
Instance Members
Is this location one character wide?
singleCharacter
ParserMessage
Instances of this class detail messages from the parser.
new ParserMessage(message: any, location: any)
Parameters
Properties
message (string)
: The message
location (Location)
: The location of the message
Statement
Statement Types.
Each of these represents a command encountered in a node body
(or as part of a nested statement)
Statement
Static Members
Represents a function statement in the node body
new Base()
Instance Members
location
Returns
Location
:
the location of this statement in the original file
Represents a blank statement in the node body
new Blank()
Extends
Base
Represents a command statement in the node body
new Command()
Extends
Base
Instance Members
arguments
Returns
Array<Expression.Base>
:
an array of expressions for this command
Represents a conditional statement in the node body
new Conditional()
Extends
Base
Static Members
Represents a clause of the conditional statement
new Clause()
Static Members
Returns the test to be applied to see if we execute this clauses's statements
If test is null or undefined, the statements should be exeuted if this clause is reached.
test
Returns
Expression
:
Returns the statements to execute if the test was succesful (or if there is no test)
statements
Returns
Array<Statement.Base>
:
an array of statements to execute
Instance Members
Clauses should be tested in order returned and the first one that passes has it's statements executed
clauses
Returns
Array<Statement.Conditional.Clause>
:
an array of clauses to test and execute.
Represents a dialog segment (a set of linegroups or text lines)
new DialogueSegment()
Extends
Statement.Group
Instance Members
identifier
Returns
string
:
the unique identifer of this segment
translationNotes
Returns
Array<string>
:
the translation notes
characterName
Returns
string
:
the character Name
Represents an expression to execute in the node body.
new Evaluate()
Extends
Base
Instance Members
expression
Returns
Expression.Base
:
the expression to evaluate
Represents a function statement in the node body
new Function()
Extends
Base
Instance Members
name
Returns
string
:
the name of the function
arguments
Returns
Array<Expression.Base>
:
an array of expressions for this function
Represents a group of statements
new Group()
Extends
Statement.Base
Instance Members
statements
Returns
Array<Statement.Base>
:
the statements that are part of this group
Represents a Hashtag in the node body
new Hashtag()
Extends
Statement.Base
Instance Members
value
Returns
string
:
the value of this hashtag (if present)
key
Returns
string
:
the key of this hashtag
Represents a line group statement (a set of statements grouped as a line of dialog)
new LineGroup()
Extends
Statement.Group
Represents a statement that links to another node
new Link()
Extends
Statement.Base
Instance Members
destination
Returns
string
:
the name of the destination node that this statement links to
Represents an option statement (a link with some display text) in the node body
new Option()
Extends
Statement.Base
Instance Members
text
Returns
string
:
the text that this statement should output
destination
Returns
string
:
the name of the destination node that this statement links to
Represents a group of options (or statements that decide if options appear)
new OptionGroup()
Extends
Statement.Group
Represents a shortcut statement (a set of statements grouped as an option)
new Shortcut()
Extends
Statement.Group
Represents a group of shortcuts (or statements that decide if options appear)
new ShortcutGroup()
Extends
Statement.Group
Represents a text statement in the node body
new Text()
Extends
Statement.Base
Instance Members
value
Returns
string
:
the text that this statement should output
text
Returns
string
:
the text that this statement should output
returnOutput
returnOutput
Returns
boolean
:
if this evaluation should return the value for display