/** * @typedef {Command[]} Script * @typedef {Word[]} Command * @typedef {object} Word * @property {string} text */ const InterCommandWhitespace = Peg.Regex(/[^\S\n;]*/y); const CommentPattern = Peg.Regex(/#.*\n/y); const PreWordWhitespace = Peg.Regex(/[^\S\n;]*/y); const BasicWord = Peg.Map(Peg.Regex(/[^\s;]+/y), ([word]) => ({ text: word, })); const WordPattern = Peg.Map( Peg.Sequence(PreWordWhitespace, BasicWord), ([_, word]) => word ); /** * Parse out a Notcl script into an easier-to-interpret representation. * No script is actually executed yet. * * @param {string} code * @returns Script */ function parseNotcl(code) { /* Preprocess */ // fold line endings code = code.replace(/(?