mondo improvements:
- add second string type - add $ as alias for stack - simplify leaf handling
This commit is contained in:
parent
40f6489111
commit
7db52b3dc2
3 changed files with 30 additions and 25 deletions
|
|
@ -1,21 +1,20 @@
|
|||
import { strudelScope, reify, fast, slow, isPattern } from '@strudel/core';
|
||||
import { strudelScope, reify, fast, slow } from '@strudel/core';
|
||||
import { registerLanguage } from '@strudel/transpiler';
|
||||
import { MondoRunner } from '../mondo/mondo.mjs';
|
||||
|
||||
let runner = new MondoRunner(strudelScope, { pipepost: true, loc: true });
|
||||
let runner = new MondoRunner(strudelScope);
|
||||
|
||||
let getLeaf = (value, token) => {
|
||||
strudelScope.leaf = (token) => {
|
||||
let { value } = token;
|
||||
const [from, to] = token.loc;
|
||||
if (strudelScope[value]) {
|
||||
if (token.type === 'plain' && strudelScope[value]) {
|
||||
// what if we want a string that happens to also be a variable name?
|
||||
// example: "s sine" -> sine is also a variable
|
||||
return reify(strudelScope[value]).withLoc(from, to);
|
||||
}
|
||||
return reify(value).withLoc(from, to);
|
||||
};
|
||||
|
||||
strudelScope.plain = getLeaf;
|
||||
strudelScope.number = getLeaf;
|
||||
strudelScope.string = getLeaf;
|
||||
|
||||
strudelScope.call = (fn, args, name) => {
|
||||
const [pat, ...rest] = args;
|
||||
if (!['seq', 'cat', 'stack'].includes(name)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue