started mini notation highlighting

currently deactivated by addMiniLocations flag
This commit is contained in:
Felix Roos 2022-02-20 23:46:45 +01:00
parent 358ba0101e
commit acd07c31ff
5 changed files with 75 additions and 2 deletions

View file

@ -1,6 +1,7 @@
import * as krill from '../krill-parser';
import * as strudel from '../../strudel.mjs';
import { Scale, Note, Interval } from '@tonaljs/tonal';
import { addMiniLocations } from './shapeshifter';
const { pure, Pattern, Fraction, stack, slowcat, sequence, timeCat, silence } = strudel;
@ -91,7 +92,18 @@ export function patternifyAST(ast: any): any {
return silence;
}
if (typeof ast.source_ !== 'object') {
return ast.source_;
if (!addMiniLocations) {
return ast.source_;
}
if (!ast.location_) {
console.warn('no location for', ast);
return ast.source_;
}
const { start, end } = ast.location_;
// return ast.source_;
// the following line expects the shapeshifter to wrap this in withLocationOffset
// because location_ is only relative to the mini string, but we need it relative to whole code
return pure(ast.source_).withLocation({ start, end });
}
return patternifyAST(ast.source_);
case 'stretch':