From ea7c079e30a4d785a2682a66e1ecb4cad3eb7e81 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 10 Feb 2022 09:09:43 +0100 Subject: [PATCH] build --- docs/dist/parse.js | 17 +++++++++++++++++ docs/dist/tunes.js | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/docs/dist/parse.js b/docs/dist/parse.js index f68f3942..62021d60 100644 --- a/docs/dist/parse.js +++ b/docs/dist/parse.js @@ -27,6 +27,12 @@ function reify(thing) { } return pure(thing); } +function minify(thing) { + if (typeof thing === "string") { + return mini(thing); + } + return reify(thing); +} const applyOptions = (parent) => (pat, i) => { const ast = parent.source_[i]; const options = ast.options_; @@ -39,6 +45,9 @@ const applyOptions = (parent) => (pat, i) => { } console.warn(`operator "${operator.type_}" not implemented`); } + if (options?.weight) { + return pat; + } const unimplemented = Object.keys(options || {}).filter((key) => key !== "operator"); if (unimplemented.length) { console.warn(`option${unimplemented.length > 1 ? "s" : ""} ${unimplemented.map((o) => `"${o}"`).join(", ")} not implemented`); @@ -52,6 +61,10 @@ export function patternifyAST(ast) { if (ast.arguments_.alignment === "v") { return stack(...children); } + const weightedChildren = ast.source_.some((child) => !!child.options_?.weight); + if (weightedChildren) { + return timeCat(...ast.source_.map((child, i) => [child.options_?.weight || 1, children[i]])); + } return sequence(...children); case "element": if (ast.source_ === "~") { @@ -94,6 +107,10 @@ export const mini = (...strings) => { return pattern; }; const m = mini; +const s = (...strings) => { + const patternified = strings.map((s2) => minify(s2)); + return stack(...patternified); +}; export const h = (string) => { const ast = krill.parse(string); return patternifyAST(ast); diff --git a/docs/dist/tunes.js b/docs/dist/tunes.js index 4eef72c4..33ada3c5 100644 --- a/docs/dist/tunes.js +++ b/docs/dist/tunes.js @@ -1,3 +1,8 @@ +export const timeCatMini = `s( + 'c3@3 [eb3, g3, [c4 d4]/2]', + 'c2 g2', + m('[eb4@5 [f4 eb4 d4]@3] [eb4 c4]/2').slow(8) +)`; export const timeCat = `stack( timeCat([3, c3], [1, stack(eb3, g3, m(c4, d4).slow(2))]), m(c2, g2),