import { escapeHtml } from "./helpers"; import { AtLeast, Choose, End, Pattern, Peek, Regex, Sequence, Use, } from "./peg"; import { EnchantedWord as EnchantedWordType, InterpolatedPiece, Script, ScriptPiece, SimplifyWord, TextWord, Word as WordType, } from "./words"; const Comment = Regex(/#[^\n]*/y) .expects("#") .map(() => []); const PreWordWhitespace = Regex(/[^\S\n;]+/y).expects("whitespace"); const EnchantedWord = Regex(/[^\]\[\}\{$\\";\s]+(?=[\s;\]]|$)/y) .map(([enchanted]) => ({ enchanted } as EnchantedWordType)) .expects("ENCHANTED_WORD"); const BackslashEscape = Regex(/\\(.)/y) .expects("\\") .map(([, char]) => ({ text: char })); const BARE_WORD_CHAR = /[^\s\\;\[]+/y; const BARE_BRACKET_WORD_CHAR = /[^\s\\;\[\]]+/y; let BracketScript: Pattern