Merge pull request #991 from tidalcycles/labeled-statements
Labeled statements
This commit is contained in:
commit
78f816978c
8 changed files with 40 additions and 0 deletions
1
packages/codemirror/themes/algoboy.mjs
vendored
1
packages/codemirror/themes/algoboy.mjs
vendored
|
|
@ -18,6 +18,7 @@ export default createTheme({
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
settings,
|
settings,
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: '#0f380f' },
|
||||||
{ tag: t.keyword, color: '#0f380f' },
|
{ tag: t.keyword, color: '#0f380f' },
|
||||||
{ tag: t.operator, color: '#0f380f' },
|
{ tag: t.operator, color: '#0f380f' },
|
||||||
{ tag: t.special(t.variableName), color: '#0f380f' },
|
{ tag: t.special(t.variableName), color: '#0f380f' },
|
||||||
|
|
|
||||||
1
packages/codemirror/themes/blackscreen.mjs
vendored
1
packages/codemirror/themes/blackscreen.mjs
vendored
|
|
@ -15,6 +15,7 @@ export default createTheme({
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
settings,
|
settings,
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: 'white' },
|
||||||
{ tag: t.keyword, color: 'white' },
|
{ tag: t.keyword, color: 'white' },
|
||||||
{ tag: t.operator, color: 'white' },
|
{ tag: t.operator, color: 'white' },
|
||||||
{ tag: t.special(t.variableName), color: 'white' },
|
{ tag: t.special(t.variableName), color: 'white' },
|
||||||
|
|
|
||||||
1
packages/codemirror/themes/bluescreen.mjs
vendored
1
packages/codemirror/themes/bluescreen.mjs
vendored
|
|
@ -18,6 +18,7 @@ export default createTheme({
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
settings,
|
settings,
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: 'white' },
|
||||||
{ tag: t.keyword, color: 'white' },
|
{ tag: t.keyword, color: 'white' },
|
||||||
{ tag: t.operator, color: 'white' },
|
{ tag: t.operator, color: 'white' },
|
||||||
{ tag: t.special(t.variableName), color: 'white' },
|
{ tag: t.special(t.variableName), color: 'white' },
|
||||||
|
|
|
||||||
1
packages/codemirror/themes/strudel-theme.mjs
vendored
1
packages/codemirror/themes/strudel-theme.mjs
vendored
|
|
@ -15,6 +15,7 @@ export default createTheme({
|
||||||
gutterForeground: '#8a919966',
|
gutterForeground: '#8a919966',
|
||||||
},
|
},
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: '#89ddff' },
|
||||||
{ tag: t.keyword, color: '#c792ea' },
|
{ tag: t.keyword, color: '#c792ea' },
|
||||||
{ tag: t.operator, color: '#89ddff' },
|
{ tag: t.operator, color: '#89ddff' },
|
||||||
{ tag: t.special(t.variableName), color: '#eeffff' },
|
{ tag: t.special(t.variableName), color: '#eeffff' },
|
||||||
|
|
|
||||||
1
packages/codemirror/themes/teletext.mjs
vendored
1
packages/codemirror/themes/teletext.mjs
vendored
|
|
@ -27,6 +27,7 @@ export default createTheme({
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
settings,
|
settings,
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: colorB },
|
||||||
{ tag: t.keyword, color: colorA },
|
{ tag: t.keyword, color: colorA },
|
||||||
{ tag: t.operator, color: mini },
|
{ tag: t.operator, color: mini },
|
||||||
{ tag: t.special(t.variableName), color: colorA },
|
{ tag: t.special(t.variableName), color: colorA },
|
||||||
|
|
|
||||||
1
packages/codemirror/themes/terminal.mjs
vendored
1
packages/codemirror/themes/terminal.mjs
vendored
|
|
@ -14,6 +14,7 @@ export default createTheme({
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
settings,
|
settings,
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: '#41FF00' },
|
||||||
{ tag: t.keyword, color: '#41FF00' },
|
{ tag: t.keyword, color: '#41FF00' },
|
||||||
{ tag: t.operator, color: '#41FF00' },
|
{ tag: t.operator, color: '#41FF00' },
|
||||||
{ tag: t.special(t.variableName), color: '#41FF00' },
|
{ tag: t.special(t.variableName), color: '#41FF00' },
|
||||||
|
|
|
||||||
1
packages/codemirror/themes/whitescreen.mjs
vendored
1
packages/codemirror/themes/whitescreen.mjs
vendored
|
|
@ -16,6 +16,7 @@ export default createTheme({
|
||||||
theme: 'light',
|
theme: 'light',
|
||||||
settings,
|
settings,
|
||||||
styles: [
|
styles: [
|
||||||
|
{ tag: t.labelName, color: 'black' },
|
||||||
{ tag: t.keyword, color: 'black' },
|
{ tag: t.keyword, color: 'black' },
|
||||||
{ tag: t.operator, color: 'black' },
|
{ tag: t.operator, color: 'black' },
|
||||||
{ tag: t.special(t.variableName), color: 'black' },
|
{ tag: t.special(t.variableName), color: 'black' },
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ export function transpiler(input, options = {}) {
|
||||||
if (isBareSamplesCall(node, parent)) {
|
if (isBareSamplesCall(node, parent)) {
|
||||||
return this.replace(withAwait(node));
|
return this.replace(withAwait(node));
|
||||||
}
|
}
|
||||||
|
if (isLabelStatement(node)) {
|
||||||
|
return this.replace(labelToP(node));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
leave(node, parent, prop, index) {},
|
leave(node, parent, prop, index) {},
|
||||||
});
|
});
|
||||||
|
|
@ -132,3 +135,33 @@ function withAwait(node) {
|
||||||
argument: node,
|
argument: node,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isLabelStatement(node) {
|
||||||
|
return node.type === 'LabeledStatement';
|
||||||
|
}
|
||||||
|
|
||||||
|
// converts label expressions to p calls: "x: y" to "y.p('x')"
|
||||||
|
// see https://github.com/tidalcycles/strudel/issues/990
|
||||||
|
function labelToP(node) {
|
||||||
|
return {
|
||||||
|
type: 'ExpressionStatement',
|
||||||
|
expression: {
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: node.body.expression,
|
||||||
|
property: {
|
||||||
|
type: 'Identifier',
|
||||||
|
name: 'p',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
type: 'Literal',
|
||||||
|
value: node.label.name,
|
||||||
|
raw: `'${node.label.name}'`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue