Revert "Support both old and new sompyler AST slot names in parser"
This reverts commit b56d84befb890c13ad5daafa327032f9ca8c76e8.
This commit is contained in:
parent
b56d84befb
commit
6be4a3297a
@ -443,10 +443,10 @@ function buildOffset(node) {
|
||||
unknownProps: collectUnknownProps(node.props, new Set(['tick'])),
|
||||
};
|
||||
for (const child of node.children) {
|
||||
if ((child.parentSlot === 'line' || child.parentSlot === 'offset') && child.slot === 'stem_note')
|
||||
if (child.parentSlot === 'line' && child.slot === 'stem_note')
|
||||
offset.stemNotes.push(buildStemNote(child));
|
||||
else if ((child.parentSlot === 'line' || child.parentSlot === 'offset') && child.slot === 'motif')
|
||||
offset.motifs.push({ label: child.positionals[0] ?? child.props.label, chord: child.props.chord ?? null });
|
||||
else if (child.parentSlot === 'line' && child.slot === 'motif')
|
||||
offset.motifs.push({ label: child.positionals[0], chord: child.props.chord ?? null });
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
@ -465,7 +465,7 @@ function buildStemNote(node) {
|
||||
weight: null,
|
||||
chainText: chainNode?.props._tmp_string ?? '',
|
||||
writeToName: writeToNode?.positionals[0] ?? null,
|
||||
clauses: (chainNode ? chainNode.children : node.children)
|
||||
clauses: (chainNode?.children ?? [])
|
||||
.filter(c => c.parentSlot === 'chain' && c.slot === 'clause')
|
||||
.map(buildClause),
|
||||
isDirty: false,
|
||||
@ -478,9 +478,9 @@ function buildClause(node) {
|
||||
type: 'clause',
|
||||
index: node.positionals[0] ?? 0,
|
||||
repeat: node.props.repeat ?? null,
|
||||
notes: node.children.filter(c => c.slot === 'note' && (c.parentSlot === 'seq' || c.parentSlot === 'clause')).map(c => ({ ...c.props })),
|
||||
pauses: node.children.filter(c => c.slot === 'pause' && (c.parentSlot === 'seq' || c.parentSlot === 'clause')).map(c => ({ length: c.props.length })),
|
||||
stacks: node.children.filter(c => c.slot === 'stack' && (c.parentSlot === 'seq' || c.parentSlot === 'clause')).map(c => ({
|
||||
notes: node.children.filter(c => c.slot === 'note' && c.parentSlot === 'seq').map(c => ({ ...c.props })),
|
||||
pauses: node.children.filter(c => c.slot === 'pause' && c.parentSlot === 'seq').map(c => ({ length: c.props.length })),
|
||||
stacks: node.children.filter(c => c.slot === 'stack' && c.parentSlot === 'seq').map(c => ({
|
||||
length: c.props.length, netlength: c.props.netlength,
|
||||
notes: c.children.filter(cn => cn.slot === 'note').map(cn => ({ ...cn.props })),
|
||||
})),
|
||||
@ -495,7 +495,7 @@ function buildMotif(node) {
|
||||
unknownProps: collectUnknownProps(node.props, new Set(['label'])),
|
||||
};
|
||||
for (const child of node.children) {
|
||||
if ((child.parentSlot === 'line' || child.parentSlot === 'motif') && child.slot === 'stem_note')
|
||||
if (child.parentSlot === 'line' && child.slot === 'stem_note')
|
||||
m.stemNotes.push(buildStemNote(child));
|
||||
}
|
||||
m.isStatic = m.stemNotes.length > 0 && !m.stemNotes.some(sn => Number.isInteger(sn.pitch));
|
||||
|
||||
@ -520,36 +520,6 @@ let nsThrew = false;
|
||||
try { parseAstLog(NS_FIXTURE); } catch (e) { nsThrew = true; }
|
||||
ok('missing slot throws', nsThrew);
|
||||
|
||||
section('Old-format AST (pre-c3b51bc sompyler) backward compat');
|
||||
const OLD_OFFSET_FIXTURE = `00 bar '001P1L1M1'
|
||||
01 bar.voice 'pi'
|
||||
02 voice.offset tick=0
|
||||
03 offset.stem_note pitch='C4'
|
||||
04 chain.clause 0 repeat=1
|
||||
05 clause.note letter='o' shift=0 length=1 netlength=1
|
||||
05 clause.pause length=1
|
||||
`;
|
||||
const oldOffset = buildModel(parseAstLog(OLD_OFFSET_FIXTURE)).bars[0].voices['pi'].offsets[0];
|
||||
ok('old-fmt: offset has stem note', oldOffset.stemNotes.length === 1);
|
||||
ok('old-fmt: stem note pitch', oldOffset.stemNotes[0].pitch === 'C4');
|
||||
ok('old-fmt: clause found via direct child', oldOffset.stemNotes[0].clauses.length === 1);
|
||||
ok('old-fmt: clause.note found', oldOffset.stemNotes[0].clauses[0].notes.length === 1);
|
||||
ok('old-fmt: clause.pause found', oldOffset.stemNotes[0].clauses[0].pauses.length === 1);
|
||||
|
||||
const OLD_MOTIF_FIXTURE = `00 bar '001P1L1M1'
|
||||
01 bar.voice 'pi'
|
||||
02 voice.motif label='oct'
|
||||
03 motif.stem_note pitch=0
|
||||
04 chain.clause 0 repeat=1
|
||||
05 clause.note letter='o' shift=0 length=1 netlength=1
|
||||
05 clause.note letter='o' shift=12 netlength=1 length=1
|
||||
`;
|
||||
const oldMotif = buildModel(parseAstLog(OLD_MOTIF_FIXTURE)).bars[0].voices['pi'].motifs[0];
|
||||
ok('old-fmt: motif stem note found', oldMotif.stemNotes.length === 1);
|
||||
ok('old-fmt: motif pitch=0 isStatic=false', oldMotif.isStatic === false);
|
||||
ok('old-fmt: motif clause found', oldMotif.stemNotes[0].clauses.length === 1);
|
||||
ok('old-fmt: motif clause notes', oldMotif.stemNotes[0].clauses[0].notes.length === 2);
|
||||
|
||||
section('line.motif invocation at offset');
|
||||
const LM_FIXTURE = `00 bar '001P1L1M1'
|
||||
01 bar.voice 'pi'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user