notations 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/notations.umd.js +3933 -12155
- package/dist/notations.umd.min.js +2 -3
- package/dist/notations.umd.min.js.map +1 -1
- package/lib/cjs/parser.js +1 -1
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/web/components/DockViewPlayground.d.ts +51 -0
- package/lib/cjs/web/components/DockViewPlayground.js +364 -0
- package/lib/cjs/web/components/DockViewPlayground.js.map +1 -0
- package/lib/cjs/web/components/NotationBlock.d.ts +35 -0
- package/lib/cjs/web/components/NotationBlock.js +219 -0
- package/lib/cjs/web/components/NotationBlock.js.map +1 -0
- package/lib/cjs/web/components/NotebookCell.d.ts +41 -0
- package/lib/cjs/web/components/NotebookCell.js +269 -0
- package/lib/cjs/web/components/NotebookCell.js.map +1 -0
- package/lib/cjs/web/components/NotebookView.d.ts +37 -0
- package/lib/cjs/web/components/NotebookView.js +379 -0
- package/lib/cjs/web/components/NotebookView.js.map +1 -0
- package/lib/cjs/web/components/SideBySideEditor.d.ts +47 -0
- package/lib/cjs/web/components/SideBySideEditor.js +171 -0
- package/lib/cjs/web/components/SideBySideEditor.js.map +1 -0
- package/lib/cjs/web/dockview.d.ts +2 -0
- package/lib/cjs/web/dockview.js +11 -0
- package/lib/cjs/web/dockview.js.map +1 -0
- package/lib/cjs/web/index.d.ts +8 -0
- package/lib/cjs/web/index.js +34 -0
- package/lib/cjs/web/index.js.map +1 -0
- package/lib/cjs/web/types/notebook.d.ts +64 -0
- package/lib/cjs/web/types/notebook.js +56 -0
- package/lib/cjs/web/types/notebook.js.map +1 -0
- package/lib/cjs/web/utils/cellFactory.d.ts +16 -0
- package/lib/cjs/web/utils/cellFactory.js +137 -0
- package/lib/cjs/web/utils/cellFactory.js.map +1 -0
- package/lib/cjs/web/utils/sourceSerializer.d.ts +19 -0
- package/lib/cjs/web/utils/sourceSerializer.js +162 -0
- package/lib/cjs/web/utils/sourceSerializer.js.map +1 -0
- package/lib/esm/parser.js +1 -1
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/web/components/DockViewPlayground.d.ts +51 -0
- package/lib/esm/web/components/DockViewPlayground.js +358 -0
- package/lib/esm/web/components/DockViewPlayground.js.map +1 -0
- package/lib/esm/web/components/NotationBlock.d.ts +35 -0
- package/lib/esm/web/components/NotationBlock.js +216 -0
- package/lib/esm/web/components/NotationBlock.js.map +1 -0
- package/lib/esm/web/components/NotebookCell.d.ts +41 -0
- package/lib/esm/web/components/NotebookCell.js +266 -0
- package/lib/esm/web/components/NotebookCell.js.map +1 -0
- package/lib/esm/web/components/NotebookView.d.ts +37 -0
- package/lib/esm/web/components/NotebookView.js +376 -0
- package/lib/esm/web/components/NotebookView.js.map +1 -0
- package/lib/esm/web/components/SideBySideEditor.d.ts +47 -0
- package/lib/esm/web/components/SideBySideEditor.js +168 -0
- package/lib/esm/web/components/SideBySideEditor.js.map +1 -0
- package/lib/esm/web/dockview.d.ts +2 -0
- package/lib/esm/web/dockview.js +3 -0
- package/lib/esm/web/dockview.js.map +1 -0
- package/lib/esm/web/index.d.ts +8 -0
- package/lib/esm/web/index.js +9 -0
- package/lib/esm/web/index.js.map +1 -0
- package/lib/esm/web/types/notebook.d.ts +64 -0
- package/lib/esm/web/types/notebook.js +50 -0
- package/lib/esm/web/types/notebook.js.map +1 -0
- package/lib/esm/web/utils/cellFactory.d.ts +16 -0
- package/lib/esm/web/utils/cellFactory.js +127 -0
- package/lib/esm/web/utils/cellFactory.js.map +1 -0
- package/lib/esm/web/utils/sourceSerializer.d.ts +19 -0
- package/lib/esm/web/utils/sourceSerializer.js +154 -0
- package/lib/esm/web/utils/sourceSerializer.js.map +1 -0
- package/package.json +41 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceSerializer.js","sourceRoot":"","sources":["../../../../src/web/utils/sourceSerializer.ts"],"names":[],"mappings":";;AAgDA,wCAYC;AAUD,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M,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,IAAI,KAAK,GAAG;YAAE,UAAU,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,GAAG;YAAE,UAAU,EAAE,CAAC;QAC/B,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,yBAAyB;aACjC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,yBAAyB;SACjC,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC;AAWD,SAAgB,mBAAmB,CAAC,IAAe,EAAE,UAAkB;IAIrE,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAqB,CAAC;QAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,OAAO;gBACL,KAAK;gBACL,GAAG,EAAE,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM;aACrC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Source serializer for converting CellModel trees back to notation source.\n *\n * This module handles serializing edited cells back into notation source text,\n * preserving formatting and structure where possible.\n */\n\nimport type { BlockItem, Block, RawBlock } from \"../../block\";\nimport type { Line } from \"../../core\";\nimport { isBlock, isLine, isRawBlock } from \"../../block\";\nimport { CellModel } from \"../types/notebook\";\n\n/**\n * Options for source serialization.\n */\nexport interface SerializerOptions {\n /**\n * Indentation string to use for nested blocks.\n * @default \" \" (two spaces)\n */\n indent?: string;\n\n /**\n * Line separator.\n * @default \"\\n\"\n */\n lineSeparator?: string;\n\n /**\n * Whether to preserve original source for unmodified cells.\n * @default true\n */\n preserveUnmodified?: boolean;\n}\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n indent: \" \",\n lineSeparator: \"\\n\",\n preserveUnmodified: true,\n};\n\n/**\n * Serializes a cell tree back to notation source.\n *\n * @param cells The cell models to serialize\n * @param options Serialization options\n * @returns The serialized notation source\n */\nexport function serializeCells(cells: CellModel[], options: SerializerOptions = {}): string {\n const opts = { ...DEFAULT_OPTIONS, ...options };\n const parts: string[] = [];\n\n for (const cell of cells) {\n const serialized = serializeCell(cell, 0, opts);\n if (serialized) {\n parts.push(serialized);\n }\n }\n\n return parts.join(opts.lineSeparator! + opts.lineSeparator!);\n}\n\n/**\n * Serializes a single cell to source.\n *\n * @param cell The cell to serialize\n * @param depth The current nesting depth\n * @param options Serialization options\n * @returns The serialized source\n */\nexport function serializeCell(cell: CellModel, depth: number, options: SerializerOptions): string {\n const indent = options.indent!.repeat(depth);\n\n // If preserving unmodified and cell has source, use it directly\n if (options.preserveUnmodified && cell.source && !cell.state.hasError) {\n // For top-level cells, return source as-is\n if (depth === 0) {\n return cell.source;\n }\n // For nested cells, indent each line\n return cell.source\n .split(\"\\n\")\n .map((line) => indent + line)\n .join(options.lineSeparator!);\n }\n\n // Otherwise, serialize from the block item\n return serializeBlockItem(cell.blockItem, depth, options);\n}\n\n/**\n * Serializes a BlockItem to source.\n *\n * @param item The block item to serialize\n * @param depth The current nesting depth\n * @param options Serialization options\n * @returns The serialized source\n */\nexport function serializeBlockItem(item: BlockItem, depth: number, options: SerializerOptions): string {\n if (isRawBlock(item)) {\n return serializeRawBlock(item as RawBlock, depth, options);\n }\n\n if (isLine(item)) {\n return serializeLine(item as Line, depth, options);\n }\n\n if (isBlock(item)) {\n return serializeBlock(item as Block, depth, options);\n }\n\n return \"\";\n}\n\n/**\n * Serializes a RawBlock to source.\n */\nfunction serializeRawBlock(rawBlock: RawBlock, depth: number, options: SerializerOptions): string {\n const indent = options.indent!.repeat(depth);\n const content = rawBlock.content;\n\n // Determine wrapper based on content type\n if (rawBlock.contentType === \"md\") {\n // Markdown content uses triple backtick or raw syntax\n return `${indent}---${options.lineSeparator}${content}${options.lineSeparator}${indent}---`;\n }\n\n if (rawBlock.contentType === \"metadata\") {\n // Metadata reference\n return `${indent}@@${content}`;\n }\n\n // Default: plain text or other content\n return content\n .split(\"\\n\")\n .map((line) => indent + line)\n .join(options.lineSeparator!);\n}\n\n/**\n * Serializes a Line to source.\n *\n * Note: This is a simplified serialization. Full Line serialization\n * would need to reconstruct atoms, spaces, embellishments, etc.\n */\nfunction serializeLine(line: Line, depth: number, options: SerializerOptions): string {\n const indent = options.indent!.repeat(depth);\n\n // For now, return a placeholder\n // Full implementation would iterate through line.atoms and serialize each\n // This would require significant work to reconstruct the DSL syntax\n return `${indent}; [Line serialization not fully implemented]`;\n}\n\n/**\n * Serializes a Block to source.\n */\nfunction serializeBlock(block: Block, depth: number, options: SerializerOptions): string {\n const indent = options.indent!.repeat(depth);\n const childIndent = options.indent!.repeat(depth + 1);\n const parts: string[] = [];\n\n // Block header\n const header = serializeBlockHeader(block);\n parts.push(`${indent}${header} {`);\n\n // Children\n for (const child of block.blockItems) {\n const childSource = serializeBlockItem(child, depth + 1, options);\n if (childSource) {\n parts.push(childSource);\n }\n }\n\n // Closing brace\n parts.push(`${indent}}`);\n\n return parts.join(options.lineSeparator!);\n}\n\n/**\n * Serializes a block header (command with parameters).\n */\nfunction serializeBlockHeader(block: Block): string {\n const type = block.blockType;\n\n switch (type) {\n case \"section\":\n return `\\\\section(\"${block.name || \"\"}\")`;\n\n case \"repeat\": {\n // RepeatBlock has repeatCount property\n const repeatCount = (block as any).repeatCount ?? 1;\n return `\\\\repeat(${repeatCount})`;\n }\n\n case \"cycle\":\n // CycleBlock has localCycle\n if (block.localCycle) {\n return `\\\\cycle(\"${block.localCycle.toString()}\")`;\n }\n return \"\\\\cycle()\";\n\n case \"beatduration\":\n if (block.localAtomsPerBeat !== null) {\n return `\\\\beatDuration(${block.localAtomsPerBeat})`;\n }\n return \"\\\\beatDuration(1)\";\n\n case \"breaks\":\n if (block.localBreaks) {\n return `\\\\breaks(${block.localBreaks.join(\", \")})`;\n }\n return \"\\\\breaks()\";\n\n case \"role\": {\n // Get first role name from localRoles\n const roleName = Array.from(block.localRoles.keys())[0] || \"\";\n return `\\\\role(\"${roleName}\")`;\n }\n\n case \"group\":\n if (block.name) {\n return `\\\\group(\"${block.name}\")`;\n }\n return \"\\\\group()\";\n\n case \"notation\":\n // Root notation block has no header\n return \"\";\n\n default:\n return `\\\\${type}()`;\n }\n}\n\n/**\n * Updates a cell's source and marks it as modified.\n *\n * @param cell The cell to update\n * @param newSource The new source text\n * @returns A new CellModel with updated source\n */\nexport function updateCellSource(cell: CellModel, newSource: string): CellModel {\n return {\n ...cell,\n source: newSource,\n };\n}\n\n/**\n * Validates cell source by attempting to parse it.\n *\n * @param source The source to validate\n * @returns Object with isValid flag and optional error message\n */\nexport function validateCellSource(source: string): {\n isValid: boolean;\n error?: string;\n} {\n // For now, just check for basic syntax issues\n // Full validation would require the notation parser\n\n // Check for balanced braces\n let braceCount = 0;\n for (const char of source) {\n if (char === \"{\") braceCount++;\n if (char === \"}\") braceCount--;\n if (braceCount < 0) {\n return {\n isValid: false,\n error: \"Unmatched closing brace\",\n };\n }\n }\n\n if (braceCount !== 0) {\n return {\n isValid: false,\n error: \"Unmatched opening brace\",\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Extracts the source range for a cell from full notation source.\n * This is a best-effort function that tries to find the cell's content\n * in the original source.\n *\n * @param cell The cell to find\n * @param fullSource The full notation source\n * @returns Source range or null if not found\n */\nexport function findCellSourceRange(cell: CellModel, fullSource: string): { start: number; end: number } | null {\n // This is a simplified implementation\n // Full implementation would need source position tracking in the parser\n\n if (isRawBlock(cell.blockItem)) {\n const rawBlock = cell.blockItem as RawBlock;\n const start = fullSource.indexOf(rawBlock.content);\n if (start >= 0) {\n return {\n start,\n end: start + rawBlock.content.length,\n };\n }\n }\n\n return null;\n}\n"]}
|
package/lib/esm/parser.js
CHANGED
|
@@ -123,9 +123,9 @@ const [parser] = G.newParser(String.raw `
|
|
|
123
123
|
Duration -> Fraction | NUMBER;
|
|
124
124
|
Fraction -> NUMBER SLASH NUMBER { newFraction } ;
|
|
125
125
|
`, {
|
|
126
|
-
allowLeftRecursion: true,
|
|
127
126
|
debug: "",
|
|
128
127
|
type: "lalr",
|
|
128
|
+
leftRecursive: true,
|
|
129
129
|
tokenHandlers: {
|
|
130
130
|
toEmbelishment: (token, tape, owner) => {
|
|
131
131
|
const [emb, pre] = owner.parseEmbelishment(token.value);
|
package/lib/esm/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAQ,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AAC3E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,MAAM,GACP,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC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IAAI,CAAC,MAAM,CAAC,CAAC;QAG5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;YAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;YAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC/D,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport * as TLEX from \"tlex\";\nimport YAML from \"yaml\";\nimport { Literal, AtomType, Note, Atom, Rest, Space, Syllable, Group, Marker } from \"./core\";\nimport { Notation, MetaData as Meta, Command, CmdParam } from \"./notation\";\nimport {\n RawEmbedding,\n ApplyLayout,\n AddAtoms,\n SetCycle,\n SetBeatDuration,\n SetBreaks,\n ActivateRole,\n CreateRole,\n CreateLine,\n Section,\n ScopedGroup,\n Repeat,\n} from \"./commands\";\n\n// TODO - Make this plugable from the client instead of hard coded\nimport * as carnatic from \"./carnatic\";\n\nconst ONE = TSU.Num.Fraction.ONE;\nconst TWO = ONE.timesNum(2);\n\n/**\n * V4 of our parser builds on V3 and has the following improvements:\n *\n * 1. Embedding Headings to demarcate sections so users dont have to use\n * explicit MD for headings.\n * 2. Unlike V3 here users break out *of* song instead instead break out \"into\"\n * song. So users spend more time writing notation and less worrying about\n * other things like headings etc.\n */\nconst [parser /*itemGraph*/] = G.newParser(\n String.raw`\n %define IdentChar /[^%!@$#&\\^|\\[\\]={}()<>+\\-,;~: \\t\\f\\r\\n\\v\\\\\\.\\'\\\"]/\n\n %token BSLASH \"\\\\\"\n %token OPEN_SQ \"[\"\n %token CLOSE_SQ \"]\"\n %token EQUALS \"=\"\n %token OPEN_PAREN \"(\"\n %token CLOSE_PAREN \")\"\n %token OPEN_BRACE \"{\"\n %token CLOSE_BRACE \"}\"\n %token SLASH \"/\"\n %token STAR \"*\"\n %token CARET \"^\"\n // %skip \"-\"\n %token COMMA \",\"\n %token SEMI_COLON \";\"\n %token COLON \":\"\n\n %token FRONT_MATTER /^---$/m { toFrontMatter }\n %token SINGLE_LINE_RAW_STRING />(.*)$/m { toSingleLineRawString }\n %token MULTI_LINE_RAW_STRING /r(#{0,})\"/ { toMultiLineRawString }\n\n %token EMBELISHMENT /~[^\\s]*/ { toEmbelishment }\n %token NUMBER /-?\\d+/ { toNumber }\n %token BOOLEAN /true|false/ { toBoolean }\n %token POST_MARKER /<<\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\"/ { toMarker }\n %token POST_MARKER /<<'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'/ { toMarker }\n %token PRE_MARKER /\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\">>/ { toMarker }\n %token PRE_MARKER /'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'>>/ { toMarker }\n %token STRING /\"([^\"\\\\\\n]|\\\\.|\\\\\\n)*\"/ { toString }\n %token STRING /'([^'\\\\\\n]|\\\\.|\\\\\\n)*'/ { toString }\n %token DOTS_IDENT /(\\.+)({IdentChar}+)/ { toOctavedNote }\n %token IDENT_DOTS /({IdentChar}+)(\\.+)/ { toOctavedNote }\n %token IDENT_COLON /{IdentChar}+:/ { toRoleSelector }\n %token IDENT /{IdentChar}+/\n %token BSLASH_IDENT /\\\\{IDENT}/ { toCommandName }\n %token BSLASH_NUMBER /\\\\{NUMBER}/\n %token HYPHEN /-/\n %skip /[ \\t\\n\\f\\r]+/\n %skip_flex \"//.*$\"\n %skip /\\/\\*.*?\\*\\//\n\n Document -> Elements\n | FRONT_MATTER Elements { prependFrontMatter }\n ;\n\n Elements -> Elements Command Atoms { appendCommand } \n | Elements RoleSelector Atoms { appendRoleSelector } \n | Elements Embedding Atoms { insertEmbedding }\n | Atoms { appendAtoms }\n ;\n\n Embedding -> SINGLE_LINE_RAW_STRING | MULTI_LINE_RAW_STRING ;\n\n Command -> BSLASH_IDENT CommandParams ? OptBlock { newCommandWithBlock } ;\n CommandParams -> OPEN_PAREN ParamList ? CLOSE_PAREN { $2 } ;\n OptBlock -> Block\n | { nullBlock }\n ;\n Block -> BlockStart Elements CLOSE_BRACE { endBlock } ;\n BlockStart -> OPEN_BRACE { beginBlock } ;\n\n ParamList -> ParamList COMMA Param { concatParamList } ;\n ParamList -> Param { newParamList };\n Param -> ParamValue { newParam } ;\n Param -> ParamKey EQUALS ParamValue { newParam } ;\n ParamKey -> IDENT ;\n ParamValue -> ( STRING | Fraction | NUMBER | BOOLEAN ) ;\n\n RoleSelector -> IDENT_COLON ;\n\n Atoms -> Atoms Atom { concatAtoms } ;\n Atoms -> { newArray } ;\n\n Atom -> Atom POST_MARKER { applyPostMarker }\n | PreMarkedAtom\n ;\n PreMarkedAtom -> Leaf\n | PRE_MARKER PreMarkedAtom { applyPreMarker }\n ;\n\n Leaf -> Space | Lit | Group | Rest ;\n Leaf -> Duration Leaf { applyDuration } ;\n Rest -> HYPHEN { newRest };\n Space -> COMMA { newSpace } \n | SEMI_COLON { newDoubleSpace } \n | UNDER_SCORE { newSilentSpace } \n ;\n\n /* - An alternative representation to support both pre and\n * post embelishment operators. Here PRE_EMBs have a higher\n * associativity over POST_EMBs\n */\n Lit -> Lit POST_EMB { litWithPostEmb }\n | PreEmbLit\n ;\n\n PreEmbLit -> LitToken \n | LitToken CARET NUMBER { litWithCaret }\n | LitToken CARET STAR { litWithCaret }\n | PRE_EMB PreEmbLit { litWithPreEmb }\n ;\n \n LitToken -> DOTS_IDENT { litToAtom }\n | IDENT { litToAtom }\n | IDENT_DOTS { litToAtom }\n | STRING { litToAtom }\n ;\n\n Group -> OPEN_SQ Atoms CLOSE_SQ { newGroup };\n\n Duration -> Fraction | NUMBER;\n Fraction -> NUMBER SLASH NUMBER { newFraction } ;\n `,\n {\n allowLeftRecursion: true,\n debug: \"\",\n type: \"lalr\",\n tokenHandlers: {\n toEmbelishment: (token: TLEX.Token, tape: TLEX.Tape, owner: Parser) => {\n const [emb, pre] = owner.parseEmbelishment(token.value);\n if (emb == null) {\n console.log(\"Skipping Embelishment: \", token.value);\n owner.errors.push(\n new TLEX.TokenizerError(\n `Invalid embelishment: ${token.value}`,\n token.start,\n 1 + token.end - token.start,\n \"InvalidEmbelishment\",\n token.value,\n ),\n );\n return null;\n }\n token.value = emb;\n token.tag = pre ? \"PRE_EMB\" : \"POST_EMB\";\n return token;\n },\n toCommandName: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n token.value = token.value.substring(1);\n return token;\n },\n toBoolean: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n token.value = token.value == \"true\";\n return token;\n },\n toNumber: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n token.value = parseInt(token.value);\n return token;\n },\n toString: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n token.value = token.value.substring(1, token.value.length - 1);\n return token;\n },\n toMarker: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n if (token.tag != \"PRE_MARKER\" && token.tag != \"POST_MARKER\") {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n const isBefore = token.tag == \"PRE_MARKER\";\n const markerText = isBefore\n ? token.value.substring(1, token.value.length - 3)\n : token.value.substring(3, token.value.length - 1);\n // console.log(\"TokVal: \", token.value, token.positions);\n // console.log(\"Marker Text: \", markerText, isBefore);\n token.value = new Marker(markerText, isBefore);\n return token;\n },\n toOctavedNote: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n if (token.tag == \"DOTS_IDENT\") {\n const octave = token.positions[1][1] - token.positions[1][0];\n const note = token.value.substring(octave);\n token.value = new Note(note, ONE, -octave);\n } else if (token.tag == \"IDENT_DOTS\") {\n const octave = token.positions[2][1] - token.positions[2][0];\n const note = token.value.substring(0, token.value.length - octave);\n token.value = new Note(note, ONE, octave);\n } else {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n return token;\n },\n toRoleSelector: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n token.value = token.value.substring(0, token.value.length - 1);\n return token;\n },\n toLineAnnotation: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n // skip the initial \"!\"\n token.value = token.value.substring(1);\n return token;\n },\n toSingleLineRawString: (token: TLEX.Token, _tape: TLEX.Tape, _owner: any) => {\n // skip the initial \">\"\n token.value = token.value.substring(1);\n return token;\n },\n toMultiLineRawString: (token: TLEX.Token, tape: TLEX.Tape, _owner: any) => {\n // consume everything until \"#<N times> as start\n const hashes = tape.substring(token.positions[1][0], token.positions[1][1]);\n const endPat = '\"' + hashes;\n const startPos = tape.index;\n const endPos = TLEX.TapeHelper.advanceAfter(tape, endPat) - endPat.length;\n if (endPos < 0) {\n throw new Error(\"EOF expected while finding end of Raw String Literal: '\" + endPat + \"'\");\n }\n token.value = tape.substring(startPos, endPos);\n return token;\n },\n toFrontMatter: (token: TLEX.Token, tape: TLEX.Tape, _owner: any) => {\n // skip the initial \">\"\n const endPat = \"\\n---\";\n const startPos = tape.index;\n const endPos = TLEX.TapeHelper.advanceAfter(tape, endPat) - endPat.length;\n if (endPos < 0) {\n throw new Error(\"EOF expected while finding end of front matter\");\n }\n token.value = tape.substring(startPos, endPos);\n // console.log(\"Found FM: \", token.value);\n return token;\n },\n },\n },\n);\n\n/**\n * A notation doc is a list of lines that are found in a single document.\n *\n * Since our document (md or html etc) can contain multiple snippets\n * all these snippets are related\n */\nimport {\n Block,\n SectionBlock,\n RepeatBlock,\n CycleBlock,\n BeatDurationBlock,\n BreaksBlock,\n RoleBlock,\n GroupBlock,\n} from \"./block\";\nimport { parseCycle } from \"./utils\";\n\n/**\n * Wrapper for a command that has a block of child commands.\n * When applied, it creates the appropriate Block subclass and applies child commands to it.\n */\nexport class BlockCommand extends Command {\n readonly innerCommand: Command;\n readonly blockCommands: Command[];\n\n constructor(innerCommand: Command, blockCommands: Command[]) {\n super(innerCommand.params);\n this.innerCommand = innerCommand;\n this.blockCommands = blockCommands;\n }\n\n get name(): string {\n return `Block(${this.innerCommand.name})`;\n }\n\n /**\n * Creates the appropriate Block subclass based on the inner command type.\n */\n private createBlock(parent: Block): Block {\n const cmd = this.innerCommand;\n\n if (cmd instanceof Section) {\n return new SectionBlock(cmd.sectionName, parent);\n } else if (cmd instanceof Repeat) {\n return new RepeatBlock(cmd.count, parent);\n } else if (cmd instanceof SetCycle) {\n const cycle = parseCycle(cmd.getParamAt(0));\n return new CycleBlock(cycle, parent);\n } else if (cmd instanceof SetBeatDuration) {\n return new BeatDurationBlock(cmd.beatDuration, parent);\n } else if (cmd instanceof SetBreaks) {\n return new BreaksBlock(cmd.pattern, parent);\n } else if (cmd instanceof CreateRole) {\n const roleName = cmd.getParamAt(0);\n return new RoleBlock(roleName, cmd.notesOnly, parent);\n } else if (cmd instanceof ScopedGroup) {\n return new GroupBlock(cmd.groupName || null, parent);\n } else {\n // Generic block for other commands\n return new Block(cmd.name.toLowerCase(), parent);\n }\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n innerCommand: this.innerCommand.debugValue(),\n blockCommands: this.blockCommands.map((cmd) => cmd.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n // Create the appropriate Block subclass\n // Cast notation as Block since Notation will extend Block\n const block = this.createBlock(notation as unknown as Block);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the notation\n notation.addBlockItem(block);\n }\n\n applyToBlock(container: Block): void {\n // Create the appropriate Block subclass\n const block = this.createBlock(container);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the container\n container.addBlockItem(block);\n }\n}\n\nexport class Parser {\n errors: (TLEX.TokenizerError | G.ParseError)[] = [];\n metadata: any = {};\n readonly commands: Command[] = [];\n // Stack to track command indices when entering blocks\n private blockStartStack: number[] = [];\n\n protected ruleHandlers = {\n newFraction: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return new TSU.Num.Fraction(children[0].value);\n } else {\n return new TSU.Num.Fraction(children[0].value, children[2].value);\n }\n },\n newGroup: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const out = new Group(...children[1].value).setDuration(TWO, true);\n return out;\n },\n litWithCaret: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = Note.fromLit(children[0].value as Literal);\n const opnode = children[2];\n const shiftValue = opnode.sym.label == \"STAR\" ? true : opnode.value;\n lit.shift = shiftValue;\n return lit;\n },\n litWithPreEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const emb = children[0];\n const lit = children[1].value as Literal;\n lit.embelishments.splice(0, 0, emb.value);\n return lit;\n },\n litWithPostEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0].value as Literal;\n const emb = children[1];\n lit.embelishments.push(emb);\n return lit;\n },\n litToAtom: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0];\n if (lit.sym.label == \"DOTS_IDENT\" || lit.sym.label == \"IDENT_DOTS\") {\n return lit.value;\n } else if (lit.sym.label == \"IDENT\") {\n // Mark this as a Literal to be processed later\n return new Literal(lit.value);\n // return role.notesOnly ? new Note(lit.value) : new Syllable(lit.value);\n } else if (lit.sym.label == \"STRING\") {\n // const role = this.snippet.currRole;\n // if (role.notesOnly) throw new Error(\"Strings cannot appear in notes only mode\");\n return new Syllable(lit.value);\n } else {\n throw new Error(\"Invalid lit: \" + lit);\n }\n },\n newSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Space();\n },\n newRest: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Rest();\n },\n newDoubleSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Space(ONE.timesNum(2));\n },\n newSilentSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Space(ONE, true);\n },\n applyPreMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const marker = children[0].value as Marker;\n const leaf = children[1].value as Atom;\n // console.log(\"marker, leaf: \", marker, leaf);\n if (!leaf.markersBefore) {\n leaf.markersBefore = [];\n }\n leaf.markersBefore.splice(0, 0, marker);\n return leaf;\n },\n applyPostMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const leaf = children[0].value as Atom;\n const marker = children[1].value as Marker;\n if (!leaf.markersAfter) {\n leaf.markersAfter = [];\n }\n leaf.markersAfter.push(marker);\n return leaf;\n },\n applyDuration: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n let dur = children[0].value as TSU.Num.Fraction | number;\n const leaf = children[1].value as Atom;\n if (typeof dur === \"number\") {\n dur = ONE.timesNum(dur);\n }\n if (leaf.TYPE == AtomType.GROUP) {\n (leaf as Group).setDuration(dur, true);\n } else {\n leaf.duration = dur;\n }\n return leaf;\n },\n newArray: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // create an array of values from all the values of child nodes\n return children.map((c) => c.value);\n },\n concatAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value;\n const atom = children[1].value;\n atoms.push(atom);\n return atoms;\n },\n newParam: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return { key: null, value: children[0].value };\n } else {\n return { key: children[0].value, value: children[2].value };\n }\n },\n newParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return [children[0].value];\n },\n concatParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const params = children[0].value;\n const newParam = children[2].value;\n params.push(newParam);\n return params;\n },\n // Block handling semantic actions\n beginBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Push current command count to track where this block's commands start\n this.blockStartStack.push(this.commands.length);\n return null;\n },\n endBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Pop the start index and extract commands added since then\n const startIndex = this.blockStartStack.pop()!;\n const blockCommands = this.commands.splice(startIndex);\n return blockCommands;\n },\n nullBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // No block present\n return null;\n },\n newCommandWithBlock: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const name = children[0].value;\n const params = children[1].value;\n const blockCommands = children[2].value as Command[] | null;\n\n const innerCommand = this.createCommand(name, params);\n\n if (blockCommands !== null) {\n // Wrap in BlockCommand\n return new BlockCommand(innerCommand, blockCommands);\n } else {\n // No block, return regular command\n return innerCommand;\n }\n },\n appendAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n prependFrontMatter: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const fm = children[0].value;\n // console.log(\"Child 0: \", fm);\n // console.log(\"Child 1: \", children[1].value);\n const data = YAML.parse(fm);\n console.log(\"Parsed FM: \", data);\n this.metadata = data;\n return children[1].value;\n },\n appendCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const command = children[1].value as Command;\n this.addCommand(command);\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n appendRoleSelector: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const roleName = children[1].value;\n const lName = roleName.toLowerCase().trim();\n this.addCommand(new ActivateRole([{ key: null, value: lName }]));\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n insertEmbedding: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // How to handle embeddings - these are just blocks\n // to escape out of song (most likely for some rendering of html/md etc)\n const rawVal = children[1].value;\n this.addCommand(new RawEmbedding([{ key: null, value: rawVal }]));\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n };\n\n constructor(_config?: any) {\n // config = config || {};\n }\n\n createCommand(name: string, params: CmdParam[]): Command {\n const lName = name.trim().toLowerCase();\n params = params || [];\n if (lName == \"line\") {\n return new CreateLine(params);\n // } else if (lName == \"meta\") { return new MetaData(params);\n } else if (lName == \"role\") {\n return new CreateRole(params);\n } else if (lName == \"layout\") {\n return new ApplyLayout(params);\n } else if (lName == \"beatduration\") {\n return new SetBeatDuration(params);\n } else if (lName == \"breaks\") {\n return new SetBreaks(params);\n } else if (lName == \"cycle\") {\n return new SetCycle(params);\n } else if (lName == \"section\") {\n return new Section(params);\n } else if (lName == \"group\") {\n return new ScopedGroup(params);\n } else if (lName == \"repeat\") {\n return new Repeat(params);\n } else {\n // Try to set this as the current role\n throw new Error(\"Invalid command: \" + lName);\n }\n }\n\n addCommand(cmd: Command): void {\n cmd.index = this.commands.length;\n this.commands.push(cmd);\n }\n\n parse(input: string): any {\n this.errors = [];\n try {\n const ptree = parser.parse(input, {\n tokenizerContext: this,\n ruleHandlers: this.ruleHandlers,\n onTokenError: (err: TLEX.TokenizerError) => {\n this.errors.push(err);\n return true;\n },\n });\n return ptree;\n } catch (err) {\n if (err instanceof G.ParseError) {\n this.errors.push(err);\n } else {\n throw err;\n }\n }\n return null;\n }\n\n parseAndBuild(input: string): [Notation, G.ParseError[]] {\n this.parse(input);\n const notation = new Notation();\n const errors: G.ParseError[] = [];\n errors.push(...this.errors);\n\n // First add the metadata then we can set it\n for (const key in this.metadata) notation.addMetaData(new Meta(key, this.metadata[key]));\n for (const cmd of this.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n }\n\n parseEmbelishment(value: string): [any, boolean] {\n return carnatic.parseEmbelishment(value);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAQ,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AAC3E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,MAAM,GACP,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AACjC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAW5B,MAAM,CAAC,MAAM,CAAe,GAAG,CAAC,CAAC,SAAS,CACxC,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkHP,EACH;IACE,K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AAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport * as TLEX from \"tlex\";\nimport YAML from \"yaml\";\nimport { Literal, AtomType, Note, Atom, Rest, Space, Syllable, Group, Marker } from \"./core\";\nimport { Notation, MetaData as Meta, Command, CmdParam } from \"./notation\";\nimport {\n RawEmbedding,\n ApplyLayout,\n AddAtoms,\n SetCycle,\n SetBeatDuration,\n SetBreaks,\n ActivateRole,\n CreateRole,\n CreateLine,\n Section,\n ScopedGroup,\n Repeat,\n} from \"./commands\";\n\n// TODO - Make this plugable from the client instead of hard coded\nimport * as carnatic from \"./carnatic\";\n\nconst ONE = TSU.Num.Fraction.ONE;\nconst TWO = ONE.timesNum(2);\n\n/**\n * V4 of our parser builds on V3 and has the following improvements:\n *\n * 1. Embedding Headings to demarcate sections so users dont have to use\n * explicit MD for headings.\n * 2. Unlike V3 here users break out *of* song instead instead break out \"into\"\n * song. So users spend more time writing notation and less worrying about\n * other things like headings etc.\n */\nconst [parser /*itemGraph*/] = G.newParser(\n String.raw`\n %define IdentChar /[^%!@$#&\\^|\\[\\]={}()<>+\\-,;~: \\t\\f\\r\\n\\v\\\\\\.\\'\\\"]/\n\n %token BSLASH \"\\\\\"\n %token OPEN_SQ \"[\"\n %token CLOSE_SQ \"]\"\n %token EQUALS \"=\"\n %token OPEN_PAREN \"(\"\n %token CLOSE_PAREN \")\"\n %token OPEN_BRACE \"{\"\n %token CLOSE_BRACE \"}\"\n %token SLASH \"/\"\n %token STAR \"*\"\n %token CARET \"^\"\n // %skip \"-\"\n %token COMMA \",\"\n %token SEMI_COLON \";\"\n %token COLON \":\"\n\n %token FRONT_MATTER /^---$/m { toFrontMatter }\n %token SINGLE_LINE_RAW_STRING />(.*)$/m { toSingleLineRawString }\n %token MULTI_LINE_RAW_STRING /r(#{0,})\"/ { toMultiLineRawString }\n\n %token EMBELISHMENT /~[^\\s]*/ { toEmbelishment }\n %token NUMBER /-?\\d+/ { toNumber }\n %token BOOLEAN /true|false/ { toBoolean }\n %token POST_MARKER /<<\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\"/ { toMarker }\n %token POST_MARKER /<<'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'/ { toMarker }\n %token PRE_MARKER /\"(([^\"\\\\\\n]|\\\\.|\\\\\\n)*)\">>/ { toMarker }\n %token PRE_MARKER /'(([^'\\\\\\n]|\\\\.|\\\\\\n)*)'>>/ { toMarker }\n %token STRING /\"([^\"\\\\\\n]|\\\\.|\\\\\\n)*\"/ { toString }\n %token STRING /'([^'\\\\\\n]|\\\\.|\\\\\\n)*'/ { toString }\n %token DOTS_IDENT /(\\.+)({IdentChar}+)/ { toOctavedNote }\n %token IDENT_DOTS /({IdentChar}+)(\\.+)/ { toOctavedNote }\n %token IDENT_COLON /{IdentChar}+:/ { toRoleSelector }\n %token IDENT /{IdentChar}+/\n %token BSLASH_IDENT /\\\\{IDENT}/ { toCommandName }\n %token BSLASH_NUMBER /\\\\{NUMBER}/\n %token HYPHEN /-/\n %skip /[ \\t\\n\\f\\r]+/\n %skip_flex \"//.*$\"\n %skip /\\/\\*.*?\\*\\//\n\n Document -> Elements\n | FRONT_MATTER Elements { prependFrontMatter }\n ;\n\n Elements -> Elements Command Atoms { appendCommand } \n | Elements RoleSelector Atoms { appendRoleSelector } \n | Elements Embedding Atoms { insertEmbedding }\n | Atoms { appendAtoms }\n ;\n\n Embedding -> SINGLE_LINE_RAW_STRING | MULTI_LINE_RAW_STRING ;\n\n Command -> BSLASH_IDENT CommandParams ? OptBlock { newCommandWithBlock } ;\n CommandParams -> OPEN_PAREN ParamList ? CLOSE_PAREN { $2 } ;\n OptBlock -> Block\n | { nullBlock }\n ;\n Block -> BlockStart Elements CLOSE_BRACE { endBlock } ;\n BlockStart -> OPEN_BRACE { beginBlock } ;\n\n ParamList -> ParamList COMMA Param { concatParamList } ;\n ParamList -> Param { newParamList };\n Param -> ParamValue { newParam } ;\n Param -> ParamKey EQUALS ParamValue { newParam } ;\n ParamKey -> IDENT ;\n ParamValue -> ( STRING | Fraction | NUMBER | BOOLEAN ) ;\n\n RoleSelector -> IDENT_COLON ;\n\n Atoms -> Atoms Atom { concatAtoms } ;\n Atoms -> { newArray } ;\n\n Atom -> Atom POST_MARKER { applyPostMarker }\n | PreMarkedAtom\n ;\n PreMarkedAtom -> Leaf\n | PRE_MARKER PreMarkedAtom { applyPreMarker }\n ;\n\n Leaf -> Space | Lit | Group | Rest ;\n Leaf -> Duration Leaf { applyDuration } ;\n Rest -> HYPHEN { newRest };\n Space -> COMMA { newSpace } \n | SEMI_COLON { newDoubleSpace } \n | UNDER_SCORE { newSilentSpace } \n ;\n\n /* - An alternative representation to support both pre and\n * post embelishment operators. Here PRE_EMBs have a higher\n * associativity over POST_EMBs\n */\n Lit -> Lit POST_EMB { litWithPostEmb }\n | PreEmbLit\n ;\n\n PreEmbLit -> LitToken \n | LitToken CARET NUMBER { litWithCaret }\n | LitToken CARET STAR { litWithCaret }\n | PRE_EMB PreEmbLit { litWithPreEmb }\n ;\n \n LitToken -> DOTS_IDENT { litToAtom }\n | IDENT { litToAtom }\n | IDENT_DOTS { litToAtom }\n | STRING { litToAtom }\n ;\n\n Group -> OPEN_SQ Atoms CLOSE_SQ { newGroup };\n\n Duration -> Fraction | NUMBER;\n Fraction -> NUMBER SLASH NUMBER { newFraction } ;\n `,\n {\n debug: \"\",\n type: \"lalr\",\n leftRecursive: true,\n tokenHandlers: {\n toEmbelishment: (token: TLEX.Token, tape: TLEX.TapeInterface, owner: any) => {\n const [emb, pre] = owner.parseEmbelishment(token.value);\n if (emb == null) {\n console.log(\"Skipping Embelishment: \", token.value);\n owner.errors.push(\n new TLEX.TokenizerError(\n `Invalid embelishment: ${token.value}`,\n token.start,\n 1 + token.end - token.start,\n \"InvalidEmbelishment\",\n token.value,\n ),\n );\n return null;\n }\n token.value = emb;\n token.tag = pre ? \"PRE_EMB\" : \"POST_EMB\";\n return token;\n },\n toCommandName: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = token.value.substring(1);\n return token;\n },\n toBoolean: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = token.value == \"true\";\n return token;\n },\n toNumber: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = parseInt(token.value);\n return token;\n },\n toString: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = token.value.substring(1, token.value.length - 1);\n return token;\n },\n toMarker: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n if (token.tag != \"PRE_MARKER\" && token.tag != \"POST_MARKER\") {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n const isBefore = token.tag == \"PRE_MARKER\";\n const markerText = isBefore\n ? token.value.substring(1, token.value.length - 3)\n : token.value.substring(3, token.value.length - 1);\n // console.log(\"TokVal: \", token.value, token.positions);\n // console.log(\"Marker Text: \", markerText, isBefore);\n token.value = new Marker(markerText, isBefore);\n return token;\n },\n toOctavedNote: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n if (token.tag == \"DOTS_IDENT\") {\n const octave = token.positions[1][1] - token.positions[1][0];\n const note = token.value.substring(octave);\n token.value = new Note(note, ONE, -octave);\n } else if (token.tag == \"IDENT_DOTS\") {\n const octave = token.positions[2][1] - token.positions[2][0];\n const note = token.value.substring(0, token.value.length - octave);\n token.value = new Note(note, ONE, octave);\n } else {\n throw new Error(\"Invalid token for converting to note: \" + token.tag);\n }\n return token;\n },\n toRoleSelector: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n token.value = token.value.substring(0, token.value.length - 1);\n return token;\n },\n toLineAnnotation: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n // skip the initial \"!\"\n token.value = token.value.substring(1);\n return token;\n },\n toSingleLineRawString: (token: TLEX.Token, _tape: TLEX.TapeInterface, _owner: any) => {\n // skip the initial \">\"\n token.value = token.value.substring(1);\n return token;\n },\n toMultiLineRawString: (token: TLEX.Token, tape: TLEX.TapeInterface, _owner: any) => {\n // consume everything until \"#<N times> as start\n const hashes = tape.substring(token.positions[1][0], token.positions[1][1]);\n const endPat = '\"' + hashes;\n const startPos = tape.index;\n const endPos = TLEX.TapeHelper.advanceAfter(tape, endPat) - endPat.length;\n if (endPos < 0) {\n throw new Error(\"EOF expected while finding end of Raw String Literal: '\" + endPat + \"'\");\n }\n token.value = tape.substring(startPos, endPos);\n return token;\n },\n toFrontMatter: (token: TLEX.Token, tape: TLEX.TapeInterface, _owner: any) => {\n // skip the initial \">\"\n const endPat = \"\\n---\";\n const startPos = tape.index;\n const endPos = TLEX.TapeHelper.advanceAfter(tape, endPat) - endPat.length;\n if (endPos < 0) {\n throw new Error(\"EOF expected while finding end of front matter\");\n }\n token.value = tape.substring(startPos, endPos);\n // console.log(\"Found FM: \", token.value);\n return token;\n },\n },\n },\n);\n\n/**\n * A notation doc is a list of lines that are found in a single document.\n *\n * Since our document (md or html etc) can contain multiple snippets\n * all these snippets are related\n */\nimport {\n Block,\n SectionBlock,\n RepeatBlock,\n CycleBlock,\n BeatDurationBlock,\n BreaksBlock,\n RoleBlock,\n GroupBlock,\n} from \"./block\";\nimport { parseCycle } from \"./utils\";\n\n/**\n * Wrapper for a command that has a block of child commands.\n * When applied, it creates the appropriate Block subclass and applies child commands to it.\n */\nexport class BlockCommand extends Command {\n readonly innerCommand: Command;\n readonly blockCommands: Command[];\n\n constructor(innerCommand: Command, blockCommands: Command[]) {\n super(innerCommand.params);\n this.innerCommand = innerCommand;\n this.blockCommands = blockCommands;\n }\n\n get name(): string {\n return `Block(${this.innerCommand.name})`;\n }\n\n /**\n * Creates the appropriate Block subclass based on the inner command type.\n */\n private createBlock(parent: Block): Block {\n const cmd = this.innerCommand;\n\n if (cmd instanceof Section) {\n return new SectionBlock(cmd.sectionName, parent);\n } else if (cmd instanceof Repeat) {\n return new RepeatBlock(cmd.count, parent);\n } else if (cmd instanceof SetCycle) {\n const cycle = parseCycle(cmd.getParamAt(0));\n return new CycleBlock(cycle, parent);\n } else if (cmd instanceof SetBeatDuration) {\n return new BeatDurationBlock(cmd.beatDuration, parent);\n } else if (cmd instanceof SetBreaks) {\n return new BreaksBlock(cmd.pattern, parent);\n } else if (cmd instanceof CreateRole) {\n const roleName = cmd.getParamAt(0);\n return new RoleBlock(roleName, cmd.notesOnly, parent);\n } else if (cmd instanceof ScopedGroup) {\n return new GroupBlock(cmd.groupName || null, parent);\n } else {\n // Generic block for other commands\n return new Block(cmd.name.toLowerCase(), parent);\n }\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n innerCommand: this.innerCommand.debugValue(),\n blockCommands: this.blockCommands.map((cmd) => cmd.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n // Create the appropriate Block subclass\n // Cast notation as Block since Notation will extend Block\n const block = this.createBlock(notation as unknown as Block);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the notation\n notation.addBlockItem(block);\n }\n\n applyToBlock(container: Block): void {\n // Create the appropriate Block subclass\n const block = this.createBlock(container);\n\n // Apply all child commands to the block\n for (const cmd of this.blockCommands) {\n cmd.applyToBlock(block);\n }\n\n // Add the block to the container\n container.addBlockItem(block);\n }\n}\n\nexport class Parser {\n errors: (TLEX.TokenizerError | G.ParseError)[] = [];\n metadata: any = {};\n readonly commands: Command[] = [];\n // Stack to track command indices when entering blocks\n private blockStartStack: number[] = [];\n\n protected ruleHandlers = {\n newFraction: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return new TSU.Num.Fraction(children[0].value);\n } else {\n return new TSU.Num.Fraction(children[0].value, children[2].value);\n }\n },\n newGroup: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const out = new Group(...children[1].value).setDuration(TWO, true);\n return out;\n },\n litWithCaret: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = Note.fromLit(children[0].value as Literal);\n const opnode = children[2];\n const shiftValue = opnode.sym.label == \"STAR\" ? true : opnode.value;\n lit.shift = shiftValue;\n return lit;\n },\n litWithPreEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const emb = children[0];\n const lit = children[1].value as Literal;\n lit.embelishments.splice(0, 0, emb.value);\n return lit;\n },\n litWithPostEmb: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0].value as Literal;\n const emb = children[1];\n lit.embelishments.push(emb);\n return lit;\n },\n litToAtom: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const lit = children[0];\n if (lit.sym.label == \"DOTS_IDENT\" || lit.sym.label == \"IDENT_DOTS\") {\n return lit.value;\n } else if (lit.sym.label == \"IDENT\") {\n // Mark this as a Literal to be processed later\n return new Literal(lit.value);\n // return role.notesOnly ? new Note(lit.value) : new Syllable(lit.value);\n } else if (lit.sym.label == \"STRING\") {\n // const role = this.snippet.currRole;\n // if (role.notesOnly) throw new Error(\"Strings cannot appear in notes only mode\");\n return new Syllable(lit.value);\n } else {\n throw new Error(\"Invalid lit: \" + lit);\n }\n },\n newSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Space();\n },\n newRest: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Rest();\n },\n newDoubleSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Space(ONE.timesNum(2));\n },\n newSilentSpace: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n return new Space(ONE, true);\n },\n applyPreMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const marker = children[0].value as Marker;\n const leaf = children[1].value as Atom;\n // console.log(\"marker, leaf: \", marker, leaf);\n if (!leaf.markersBefore) {\n leaf.markersBefore = [];\n }\n leaf.markersBefore.splice(0, 0, marker);\n return leaf;\n },\n applyPostMarker: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const leaf = children[0].value as Atom;\n const marker = children[1].value as Marker;\n if (!leaf.markersAfter) {\n leaf.markersAfter = [];\n }\n leaf.markersAfter.push(marker);\n return leaf;\n },\n applyDuration: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n let dur = children[0].value as TSU.Num.Fraction | number;\n const leaf = children[1].value as Atom;\n if (typeof dur === \"number\") {\n dur = ONE.timesNum(dur);\n }\n if (leaf.TYPE == AtomType.GROUP) {\n (leaf as Group).setDuration(dur, true);\n } else {\n leaf.duration = dur;\n }\n return leaf;\n },\n newArray: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // create an array of values from all the values of child nodes\n return children.map((c) => c.value);\n },\n concatAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value;\n const atom = children[1].value;\n atoms.push(atom);\n return atoms;\n },\n newParam: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n if (children.length == 1) {\n return { key: null, value: children[0].value };\n } else {\n return { key: children[0].value, value: children[2].value };\n }\n },\n newParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n return [children[0].value];\n },\n concatParamList: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const params = children[0].value;\n const newParam = children[2].value;\n params.push(newParam);\n return params;\n },\n // Block handling semantic actions\n beginBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Push current command count to track where this block's commands start\n this.blockStartStack.push(this.commands.length);\n return null;\n },\n endBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // Pop the start index and extract commands added since then\n const startIndex = this.blockStartStack.pop()!;\n const blockCommands = this.commands.splice(startIndex);\n return blockCommands;\n },\n nullBlock: (_rule: G.Rule, _parent: G.PTNode, ..._children: G.PTNode[]) => {\n // No block present\n return null;\n },\n newCommandWithBlock: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const name = children[0].value;\n const params = children[1].value;\n const blockCommands = children[2].value as Command[] | null;\n\n const innerCommand = this.createCommand(name, params);\n\n if (blockCommands !== null) {\n // Wrap in BlockCommand\n return new BlockCommand(innerCommand, blockCommands);\n } else {\n // No block, return regular command\n return innerCommand;\n }\n },\n appendAtoms: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const atoms = children[0].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n prependFrontMatter: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const fm = children[0].value;\n // console.log(\"Child 0: \", fm);\n // console.log(\"Child 1: \", children[1].value);\n const data = YAML.parse(fm);\n console.log(\"Parsed FM: \", data);\n this.metadata = data;\n return children[1].value;\n },\n appendCommand: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const command = children[1].value as Command;\n this.addCommand(command);\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n appendRoleSelector: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n const roleName = children[1].value;\n const lName = roleName.toLowerCase().trim();\n this.addCommand(new ActivateRole([{ key: null, value: lName }]));\n\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n insertEmbedding: (rule: G.Rule, parent: G.PTNode, ...children: G.PTNode[]) => {\n // How to handle embeddings - these are just blocks\n // to escape out of song (most likely for some rendering of html/md etc)\n const rawVal = children[1].value;\n this.addCommand(new RawEmbedding([{ key: null, value: rawVal }]));\n const atoms = children[2].value as Atom[];\n if (atoms.length > 0) {\n this.addCommand(new AddAtoms(...atoms));\n }\n return null;\n },\n };\n\n constructor(_config?: any) {\n // config = config || {};\n }\n\n createCommand(name: string, params: CmdParam[]): Command {\n const lName = name.trim().toLowerCase();\n params = params || [];\n if (lName == \"line\") {\n return new CreateLine(params);\n // } else if (lName == \"meta\") { return new MetaData(params);\n } else if (lName == \"role\") {\n return new CreateRole(params);\n } else if (lName == \"layout\") {\n return new ApplyLayout(params);\n } else if (lName == \"beatduration\") {\n return new SetBeatDuration(params);\n } else if (lName == \"breaks\") {\n return new SetBreaks(params);\n } else if (lName == \"cycle\") {\n return new SetCycle(params);\n } else if (lName == \"section\") {\n return new Section(params);\n } else if (lName == \"group\") {\n return new ScopedGroup(params);\n } else if (lName == \"repeat\") {\n return new Repeat(params);\n } else {\n // Try to set this as the current role\n throw new Error(\"Invalid command: \" + lName);\n }\n }\n\n addCommand(cmd: Command): void {\n cmd.index = this.commands.length;\n this.commands.push(cmd);\n }\n\n parse(input: string): any {\n this.errors = [];\n try {\n const ptree = parser.parse(input, {\n tokenizerContext: this,\n ruleHandlers: this.ruleHandlers,\n onTokenError: (err: TLEX.TokenizerError) => {\n this.errors.push(err);\n return true;\n },\n });\n return ptree;\n } catch (err) {\n if (err instanceof G.ParseError) {\n this.errors.push(err);\n } else {\n throw err;\n }\n }\n return null;\n }\n\n parseAndBuild(input: string): [Notation, G.ParseError[]] {\n this.parse(input);\n const notation = new Notation();\n const errors: G.ParseError[] = [];\n errors.push(...this.errors);\n\n // First add the metadata then we can set it\n for (const key in this.metadata) notation.addMetaData(new Meta(key, this.metadata[key]));\n for (const cmd of this.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n }\n\n parseEmbelishment(value: string): [any, boolean] {\n return carnatic.parseEmbelishment(value);\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import SideBySideEditor, { SideBySideEditorConfig } from "./SideBySideEditor";
|
|
2
|
+
import { Notation } from "../../notation";
|
|
3
|
+
import { GlobalBeatLayout } from "../../beats";
|
|
4
|
+
export interface DockViewPlaygroundConfig {
|
|
5
|
+
initialSource?: string;
|
|
6
|
+
showConsole?: boolean;
|
|
7
|
+
persistLayout?: boolean;
|
|
8
|
+
storageKey?: string;
|
|
9
|
+
layoutVersion?: number;
|
|
10
|
+
syncScroll?: boolean;
|
|
11
|
+
markdownParser?: (content: string) => string;
|
|
12
|
+
editorConfig?: Partial<SideBySideEditorConfig>;
|
|
13
|
+
onSourceChange?: (source: string) => void;
|
|
14
|
+
onNotationParsed?: (notation: Notation, beatLayout: GlobalBeatLayout) => void;
|
|
15
|
+
onParseError?: (errors: any[]) => void;
|
|
16
|
+
isDarkMode?: () => boolean;
|
|
17
|
+
editorClass?: string;
|
|
18
|
+
outputClass?: string;
|
|
19
|
+
}
|
|
20
|
+
export default class DockViewPlayground {
|
|
21
|
+
readonly container: HTMLElement;
|
|
22
|
+
readonly config: DockViewPlaygroundConfig;
|
|
23
|
+
private dockview;
|
|
24
|
+
private sideBySideEditor;
|
|
25
|
+
private consoleOutput;
|
|
26
|
+
private consoleEntries;
|
|
27
|
+
constructor(container: HTMLElement, config?: DockViewPlaygroundConfig);
|
|
28
|
+
get editor(): SideBySideEditor | null;
|
|
29
|
+
get source(): string;
|
|
30
|
+
set source(value: string);
|
|
31
|
+
log(message: string, level?: "info" | "error" | "warning"): void;
|
|
32
|
+
clearConsole(): void;
|
|
33
|
+
render(): boolean;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
resetLayout(): void;
|
|
36
|
+
private _consoleVisible;
|
|
37
|
+
isConsoleVisible(): boolean;
|
|
38
|
+
showConsole(): void;
|
|
39
|
+
hideConsole(): void;
|
|
40
|
+
toggleConsole(): boolean;
|
|
41
|
+
private init;
|
|
42
|
+
private isDarkMode;
|
|
43
|
+
private saveLayout;
|
|
44
|
+
private loadLayout;
|
|
45
|
+
private createComponent;
|
|
46
|
+
private createDefaultLayout;
|
|
47
|
+
private createEditorPanel;
|
|
48
|
+
private createOutputPanel;
|
|
49
|
+
private createConsolePanel;
|
|
50
|
+
private renderConsoleEntry;
|
|
51
|
+
}
|