Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SakuraScript

Sakura Script Parser/Builder

Hierarchy

  • SakuraScript

Index

Interfaces

Constructors

Properties

Methods

Constructors

constructor

Properties

tokens

tokens

Static tagMatchers

tagMatchers: TagMatcher[] = [{re: /^\\([h0])/, match: (group) => new SakuraScriptToken.Scope(0, group[1] as "h" | "0")},{re: /^\\([u1])/, match: (group) => new SakuraScriptToken.Scope(1, group[1] as "u" | "1")},{re: /^\\p\[(\d+)\]/, match: (group) => new SakuraScriptToken.Scope(Number(group[1]), "bracket")},{re: /^\\p(\d)/, match: (group) => new SakuraScriptToken.Scope(Number(group[1]), "nobracket")},{re: /^\\s(\d)/, match: (group) => new SakuraScriptToken.Surface(Number(group[1]), false)},{re: /^\\s\[([^\]]+)\]/, match: (group) =>isNaN(group[1] as any) ?new SakuraScriptToken.SurfaceAlias(group[1]) :new SakuraScriptToken.Surface(Number(group[1]), true)},{re: /^\\b(\d)/, match: (group) => new SakuraScriptToken.Balloon(Number(group[1]), false)},{re: /^\\b\[([^\]]+)\]/, match: (group) => new SakuraScriptToken.Balloon(Number(group[1]), true)},{re: /^\\i(\d)/, match: (group) => new SakuraScriptToken.PlayAnimation(Number(group[1]), false)},{re: /^\\i\[(\d+)\]/, match: (group) => new SakuraScriptToken.PlayAnimation(Number(group[1]), true)},{re: /^\\i\[(\d+),wait\]/, match: (group) => new SakuraScriptToken.PlayAnimationWait(Number(group[1]))},{re: /^\\w(\d)/, match: (group) => new SakuraScriptToken.SimpleWait(Number(group[1]))},{re: /^\\_w\[(\d+)\]/, match: (group) => new SakuraScriptToken.PreciseWait(Number(group[1]))},{re: /^\\__w\[animation,(\d+)\]/, match: (group) => new SakuraScriptToken.WaitAnimationEnd(Number(group[1]))},{re: /^\\__w\[clear\]/, match: () => new SakuraScriptToken.ResetBeginning()},{re: /^\\__w\[(\d+)\]/, match: (group) => new SakuraScriptToken.WaitFromBeginning(Number(group[1]))},{re: /^\\_q/, match: () => new SakuraScriptToken.ToggleQuick()},{re: /^\\_s\[([^\]]+)\]/, match: (group) =>new SakuraScriptToken.ToggleSynchronize(splitargs(group[1]).map((n) => Number(n)))},{re: /^\\_s/, match: () => new SakuraScriptToken.ToggleSynchronize()},{re: /^\\t/, match: () => new SakuraScriptToken.TimeCritical()},{re: /^\\x(\[noclear\])?/, match: (group) => new SakuraScriptToken.WaitClick(Boolean(group[1])) },{re: /^\\\*/, match: () => new SakuraScriptToken.NoChoiceTimeout()},{re: /^\\q\[((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const args = splitargs(group[1]);if (/^On/.test(args[1])) {return new SakuraScriptToken.EventChoice(args[0], args[1], args.slice(2));} else if (/^script:/.test(args[1])) {return new SakuraScriptToken.ScriptChoice(args[0], args[1].replace(/^script:/, ""));} else {return new SakuraScriptToken.ReferencesChoice(args[0], args.slice(1));}}},{re: /^\\__q\[((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const args = splitargs(group[1]);if (/^On/.test(args[0])) {return new SakuraScriptToken.BeginEventChoice(args[0], args.slice(1));} else if (/^script:/.test(args[0])) {return new SakuraScriptToken.BeginScriptChoice(args[0].replace(/^script:/, ""));} else {return new SakuraScriptToken.BeginReferencesChoice(args);}}},{re: /^\\__q/, match: () => new SakuraScriptToken.EndChoice()},{re: /^\\q(\d*)\[((?:\\\\|\\\]|[^\]])+)\]\[((?:\\\\|\\\]|[^\]])+)\]/, match: (group) =>new SakuraScriptToken.OldReferenceChoice(group[3], group[2], group[1])},{re: /^\\_a\[((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const args = splitargs(group[1]);if (/^On/.test(args[0])) {return new SakuraScriptToken.BeginEventAnchor(args[0], args.slice(1));} else if (/^script:/.test(args[0])) {return new SakuraScriptToken.BeginScriptAnchor(args[0].replace(/^script:/, ""));} else {return new SakuraScriptToken.BeginReferencesAnchor(args);}}},{re: /^\\_a/, match: () => new SakuraScriptToken.EndAnchor()},{re: /^\\n\[half\]/, match: () => new SakuraScriptToken.HalfLineBreak()},{re: /^\\n\[(\d+)\]/, match: (group) => new SakuraScriptToken.PercentLineBreak(Number(group[1]))},{re: /^\\n/, match: () => new SakuraScriptToken.LineBreak()},{re: /^\\_n/, match: () => new SakuraScriptToken.ToggleNoAutoLineBreak()},{re: /^\\_l\[([^\]]+)\]/, match: (group) => {const [x, y] = splitargs(group[1]);return new SakuraScriptToken.Location(x, y);}},{re: /^\\_b\[((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const args = splitargs(group[1]);if (args[1] === "inline") {return new SakuraScriptToken.InlineImage(args[0], args.slice(2));} else {return new SakuraScriptToken.Image(args[0], Number(args[1]), Number(args[2]), args.slice(3));}}},{re: /^\\f\[([^\]]+)\]/, match: (group) => {const [name, ...args] = splitargs(group[1]);switch (name) {case "name": return new SakuraScriptToken.Font.Name(args);case "height": return new SakuraScriptToken.Font.Height(args[0]);case "outline":case "bold":case "italic":case "strike":case "underline":case "sub":case "sup":return new fontClassHash[name](args[0]);case "default": return new SakuraScriptToken.Font.Default();case "anchor.font.color": return new SakuraScriptToken.Font.AnchorFontColorOld(args);default:if (/color$/.test(name)) {return new fontClassHash[name](args);} else { // style, methodreturn new fontClassHash[name](args[0]);}}}},{re: /^\\4/, match: () => new SakuraScriptToken.BeFar()},{re: /^\\5/, match: () => new SakuraScriptToken.BeNear()},{re: /^\\c/, match: () => new SakuraScriptToken.Clear()},{re: /^\\e/, match: () => new SakuraScriptToken.End()},{re: /^\\z/, match: () => new SakuraScriptToken.OldChoiceEnd()},{re: /^\\-/, match: () => new SakuraScriptToken.Halt()},{re: /^\\\\/, match: () => new SakuraScriptToken.EscapeChar()},{re: /^\\!\[anim,((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [command, id, ...args] = splitargs(group[1]);return new SakuraScriptToken.Animation(command, Number(id), args);}},{re: /^\\!\[bind,((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [category, parts, dressUp] = splitargs(group[1]);return new SakuraScriptToken.Bind(category, parts, dressUp != null ? Number(dressUp) === 1 : null);}},{re: /^\\!\[moveasync,cancel\]/, match: () => new SakuraScriptToken.MoveAsyncCancel()},{re: /^\\!\[move(async)?,((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const useClass = group[1] ? SakuraScriptToken.MoveAsync : SakuraScriptToken.Move;const args = splitargs(group[2]);if (/^--/.test(args[0])) { // newconst argsHash: {[name: string]: string | undefined} = {};for (const arg of args) {const result = arg.match("\s*--([^=]+)=(.*?)\s*");if (result) {argsHash[result[1].toLowerCase()] = result[2];}}return new useClass(Number(argsHash["x"]),Number(argsHash["y"]),argsHash["time"] == null ? undefined : Number(argsHash["time"]),argsHash["base"],argsHash["base-offset"],argsHash["move-offset"],true,);} else { // oldconst [x, y, time, base, baseOffset, moveOffset] = args;return new useClass(Number(x),Number(y),time == null ? undefined : Number(time),base,baseOffset,moveOffset,false,);}}},{re: /^\\!\[lock,repaint\]/, match: () => new SakuraScriptToken.LockRepaint()},{re: /^\\!\[unlock,repaint\]/, match: () => new SakuraScriptToken.UnlockRepaint()},{re: /^\\!\[set,((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [id, ...args] = splitargs(group[1]);return new SakuraScriptToken.Set(id, args);}},{re: /^\\!\[open,((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [command, ...args] = splitargs(group[1]);return new SakuraScriptToken.Open(command, args);}},{re: /^\\!\[close,((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [command, ...args] = splitargs(group[1]);return new SakuraScriptToken.Close(command, args);}},{re: /^\\__c/, match: () => new SakuraScriptToken.OpenCommunicateBox()},{re: /^\\__t/, match: () => new SakuraScriptToken.OpenTeachBox()},{re: /^\\!\[\s*raise\s*,\s*((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [event, ...references] = splitargs(group[1]);return new SakuraScriptToken.Raise(event, references);}},{re: /^\\!\[\s*timerraise\s*,\s*((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [period, repeatCount, event, ...args] = splitargs(group[1]);return new SakuraScriptToken.TimerRaise(Number(period), Number(repeatCount), event, args);}},{re: /^\\!\[\s*notify\s*,\s*((?:\\\\|\\\]|[^\]])+)\]/, match: (group) => {const [event, ...references] = splitargs(group[1]);return new SakuraScriptToken.Notify(event, references);}},{re: /^\\!\[\*\]/, match: () => new SakuraScriptToken.Marker()},{re: /^\\_u\[([A-Fa-fXx0-9]+)\]/, match: (group) => new SakuraScriptToken.UCSChar(Number(group[1]))},{re: /^\\_m\[([A-Fa-fXx0-9]+)\]/, match: (group) => new SakuraScriptToken.AsciiChar(Number(group[1]))},{re: /^\\&\[([A-Za-z0-9]+)\]/, match: (group) => new SakuraScriptToken.EntityChar(group[1])},{re: /^\\[C67+v8]/, match: (group) => new SakuraScriptToken.NotImplemented(group[0])}, // not implemented quick{re: /^\\_[+V]/, match: (group) => new SakuraScriptToken.NotImplemented(group[0])}, // not implemented quick{re: /^\\[8j]\[.*?\]/, match: (group) => new SakuraScriptToken.NotImplemented(group[0])}, // not implemented quick{re: /^\\_[!?v]\[.*?\]/, match: (group) => new SakuraScriptToken.NotImplemented(group[0])}, // not implemented quick{re: /^\\!\[.*?\]/, match: (group) => new SakuraScriptToken.NotImplemented(group[0])}, // not implemented quick{re: /^./, match: (group) => new SakuraScriptToken.SimpleChar(group[0])},]

Methods

toObject

  • toObject(): object[]
  • make SakuraScript object

    Returns object[]

    SakuraScript object

toSakuraScript

  • toSakuraScript(): string
  • make SakuraScript string

    Returns string

    SakuraScript string

Static fromObject

  • make instance from SakuraScript object

    Parameters

    • json: Array<object>

      SakuraScript object

    Returns SakuraScript

    SakuraScript

Static parse

  • make instance from SakuraScript string

    Parameters

    • script: string

      SakuraScript string

    Returns SakuraScript

    SakuraScript

Generated using TypeDoc