All pages
Powered by GitBook
1 of 6

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Utility

Class in Yarn.Compiler

Inherits from System.Object

Summary

Utility methods for working with line tags.

public static class Utility

Methods

Name
Description

Given Yarn source code, adds line tags to the ends of all lines that need one and do not already have one.

Finds and collates every jump in every node.

Generates a Yarn script that contains a node that declares variables.

Parses a string of Yarn source code, and produces a FileParseResult and (if there were any problems) a collection of diagnostics.

AddTagsToLines(string,ICollection)
DetermineNodeConnections(string[])
ExtractStringBlocks(IEnumerable)
GenerateYarnFileWithDeclarations(IEnumerable<Yarn.Compiler.Declaration>,string,IEnumerable,IDictionary<string, string>)
ParseSource(string)

ParseSource(string)

Method in Utility

Summary

Parses a string of Yarn source code, and produces a FileParseResult and (if there were any problems) a collection of diagnostics.

public static (FileParseResult, IEnumerable<Diagnostic>) ParseSource(string source)

Parameters

Name
Description

string source

The source code to parse.

Returns

A tuple containing a that stores the parse tree and tokens, and a collection of objects that describe problems in the source code.

FileParseResult
Diagnostic

AddTagsToLines(string,ICollection<string>)

Method in Utility

Summary

Given Yarn source code, adds line tags to the ends of all lines that need one and do not already have one.

public static string AddTagsToLines(string contents, ICollection<string> existingLineTags = null)

Remarks

This method ensures that it does not generate line tags that are already present in the file, or present in the existingLineTags collection.

Line tags are added to any line of source code that contains user-visible text: lines, options, and shortcut options.

Parameters

Name
Description

The modified source code, with line tags added.

GenerateYarnFileWithDeclarations(IEnumerable<Yarn.Compiler.Declaration>,string,IEnumerable<string>,I

Method in

Generates a Yarn script that contains a node that declares variables.

This method is intended to be called by tools that let the user manage variable declarations. Such tools can read the existing variable declarations in from a script (by compiling the script with the value set to ), allow the user to make changes, and then write the changes to disk by calling this method and saving the results.

Name
Description

DetermineNodeConnections(string[])

Method in

Finds and collates every jump in every node.

Name
Description

string contents

The source code to add line tags to.

System.Collections.Generic.ICollection<string> existingLineTags

The collection of line tags already exist elsewhere in the source code; the newly added line tags will not be duplicates of any in this collection.

Returns

A list of lists of GraphingNode each containing a node, its jumps, and any positional info.

string[] YarnFileContents

The collection of yarn file content to parse and walk

Summary

Parameters

Returns

Utility
public static List<List<GraphingNode>> DetermineNodeConnections(string[] YarnFileContents)

A string containing a Yarn script that declares the specified variables.

public static string GenerateYarnFileWithDeclarations(
    IEnumerable<Yarn.Compiler.Declaration> declarations,
    string title = "Program",
    IEnumerable<string> tags = null,
    IDictionary<string, string> headers = null)

Summary

Remarks

Parameters

Utility
CompilationType
DeclarationsOnly

ExtractStringBlocks(IEnumerable<Node>)

Method in

Name
Description
public static List<List<string>> ExtractStringBlocks(IEnumerable<Node> nodes)

System.Collections.Generic.IEnumerable<Yarn.Node> nodes

Summary

Parameters

Utility

System.Collections.Generic.IEnumerable<Yarn.Compiler.Declaration> declarations

The collection of objects to include in the output.

string title

The title of the node that should be generated.

System.Collections.Generic.IEnumerable<string> tags

The collection of tags that should be generated for the node. If this is null , no tags will be generated.

System.Collections.Generic.IDictionary<string, string> headers

The collection of additional headers that should be generated for the node. If this is null , no additional headers will be generated.

Returns

Declaration