diff --git a/apps/generate/templates.ts b/apps/generate/templates.ts new file mode 100644 index 0000000..57c8ddc --- /dev/null +++ b/apps/generate/templates.ts @@ -0,0 +1,5 @@ +const definitionTemplate = () => ` +import { arg, contextVariable } "@puredit/parser"; +import type { Projection } from "@puredit/projections/types"; +import { tsParser } from "./parser"; +`; diff --git a/exp.js b/exp.js new file mode 100644 index 0000000..87f4328 --- /dev/null +++ b/exp.js @@ -0,0 +1,26 @@ +function process(input) { + let parts = []; + for (let from = 0, to = 0; to < input.length; to++) { + if (input[to] === "{") { + parts.push(input.slice(from, to)); + from = to + 1; + while (from < input.length && input[from] !== "}") { + from += 1; + } + let variables = input + .slice(to + 1, from) + .split(",") + .map((name) => name.trim()); + parts.push(variables); + to = from; + from += 1; + } + } + return parts; +} + +console.log( + process( + "replace {target} in column {columnTarget, columnSource} with {replacement}" + ) +);