mercury-lang
Advanced tools
Comparing version 1.5.4 to 1.5.5
{ | ||
"name": "mercury-lang", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Parser for the mercury live coding language", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,3 +26,3 @@ //==================================================================== | ||
// create a Parser object from our grammar | ||
let parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); | ||
let parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar), { keepHistory: false }); | ||
@@ -43,5 +43,7 @@ try { | ||
} else { | ||
console.log(parser.results[0]); | ||
// console.log(parser.results[0]); | ||
} | ||
} | ||
// remove other results | ||
parser.results.length = 1; | ||
// build the tokenized syntax tree | ||
@@ -48,0 +50,0 @@ syntaxTree['@main'].push(parser.results[0]); |
@@ -18,3 +18,3 @@ //==================================================================== | ||
function parseFile(f){ | ||
async function parseFile(f){ | ||
let file = fs.readFileSync(f, 'utf-8'); | ||
@@ -27,3 +27,3 @@ let name = path.parse(f).name; | ||
// store syntax tree result in variable | ||
let result = Mercury(file); | ||
let result = await Mercury(file); | ||
// end time of parsing | ||
@@ -30,0 +30,0 @@ time = Date.now() - time; |
@@ -0,11 +1,15 @@ | ||
// combine multiple effects modulated in time by lists | ||
// to create interesting synthesized sounds | ||
set tempo 132 | ||
set crossFade 1000 | ||
set scale minor c | ||
list str stretch([1 2 3 4] 10) | ||
list str2 stretchFloat([1 2 3 4] 10) | ||
list str3 stretchF([1 2 3 4] 10) | ||
list str4 lace([1 2 3 4] [4 3 2 1]) | ||
print str | ||
print str4 | ||
//silence | ||
new synth saw note([0 1 [12 24 19 36]] 0) name(syn) | ||
// modulate the length of the note with a cosine function | ||
set syn shape(1 cosine(128 3.14 50 300)) time(1/16) | ||
// randomnes to the slide between notes and the overdrive fx | ||
set syn slide([[100 0] 0 0]) fx(drive random(4 2 15)) | ||
// slowly rise the filter cutoff frequency | ||
set syn fx(filter low spread(32 200 3500) 0.6) | ||
// change delaytimes every 16 notes | ||
set syn fx(delay repeat([1/32 3/16] 16) 1/8 0.8) |
@@ -15,80 +15,298 @@ { | ||
], | ||
"silence": false | ||
}, | ||
"variables": { | ||
"str": [ | ||
1, | ||
1, | ||
1, | ||
2, | ||
2, | ||
2, | ||
3, | ||
3, | ||
3, | ||
4 | ||
"silence": false, | ||
"tempo": [ | ||
132 | ||
], | ||
"str2": [ | ||
1, | ||
1.3333333333333335, | ||
1.6666666666666665, | ||
2, | ||
2.333333333333333, | ||
2.6666666666666665, | ||
3, | ||
3.3333333333333335, | ||
3.6666666666666665, | ||
4 | ||
"crossFade": [ | ||
1000 | ||
], | ||
"str3": [ | ||
1, | ||
1.3333333333333335, | ||
1.6666666666666665, | ||
2, | ||
2.333333333333333, | ||
2.6666666666666665, | ||
3, | ||
3.3333333333333335, | ||
3.6666666666666665, | ||
4 | ||
], | ||
"str4": [ | ||
1, | ||
4, | ||
2, | ||
3, | ||
3, | ||
2, | ||
4, | ||
1 | ||
"scale": [ | ||
"minor", | ||
"c" | ||
] | ||
}, | ||
"objects": {}, | ||
"groups": {}, | ||
"print": [ | ||
[ | ||
1, | ||
1, | ||
1, | ||
2, | ||
2, | ||
2, | ||
3, | ||
3, | ||
3, | ||
4 | ||
], | ||
[ | ||
1, | ||
4, | ||
2, | ||
3, | ||
3, | ||
2, | ||
4, | ||
1 | ||
"variables": {}, | ||
"objects": { | ||
"syn": { | ||
"object": "synth", | ||
"type": "saw", | ||
"functions": { | ||
"group": [], | ||
"time": [ | ||
"1/16" | ||
], | ||
"note": [ | ||
[ | ||
0, | ||
1, | ||
[ | ||
12, | ||
24, | ||
19, | ||
36 | ||
] | ||
], | ||
0 | ||
], | ||
"env": [ | ||
1, | ||
[ | ||
300, | ||
298, | ||
294, | ||
286, | ||
276, | ||
264, | ||
250, | ||
234, | ||
216, | ||
197, | ||
178, | ||
159, | ||
140, | ||
122, | ||
105, | ||
90, | ||
77, | ||
66, | ||
58, | ||
52, | ||
50, | ||
50, | ||
53, | ||
60, | ||
68, | ||
80, | ||
94, | ||
109, | ||
126, | ||
144, | ||
163, | ||
183, | ||
202, | ||
220, | ||
237, | ||
253, | ||
267, | ||
279, | ||
288, | ||
295, | ||
299, | ||
299, | ||
297, | ||
292, | ||
284, | ||
274, | ||
261, | ||
246, | ||
229, | ||
212, | ||
193, | ||
174, | ||
154, | ||
136, | ||
118, | ||
102, | ||
87, | ||
74, | ||
64, | ||
56, | ||
51, | ||
50, | ||
51, | ||
55, | ||
61, | ||
71, | ||
83, | ||
97, | ||
113, | ||
130, | ||
149, | ||
168, | ||
187, | ||
206, | ||
224, | ||
241, | ||
257, | ||
270, | ||
281, | ||
290, | ||
296, | ||
299, | ||
299, | ||
296, | ||
291, | ||
282, | ||
271, | ||
258, | ||
242, | ||
225, | ||
207, | ||
188, | ||
169, | ||
150, | ||
131, | ||
114, | ||
98, | ||
84, | ||
72, | ||
62, | ||
55, | ||
51, | ||
50, | ||
51, | ||
56, | ||
63, | ||
74, | ||
86, | ||
101, | ||
117, | ||
135, | ||
153, | ||
173, | ||
192, | ||
211, | ||
228, | ||
245, | ||
260, | ||
273, | ||
284, | ||
292, | ||
297, | ||
299, | ||
299, | ||
295, | ||
289, | ||
280, | ||
268 | ||
] | ||
], | ||
"beat": [ | ||
1 | ||
], | ||
"amp": [ | ||
0.7 | ||
], | ||
"wave2": [ | ||
"saw", | ||
0 | ||
], | ||
"add_fx": [ | ||
[ | ||
"drive", | ||
[ | ||
3, | ||
3, | ||
13, | ||
4 | ||
] | ||
], | ||
[ | ||
"filter", | ||
"low", | ||
[ | ||
200, | ||
303, | ||
406, | ||
509, | ||
612, | ||
715, | ||
818, | ||
921, | ||
1025, | ||
1128, | ||
1231, | ||
1334, | ||
1437, | ||
1540, | ||
1643, | ||
1746, | ||
1850, | ||
1953, | ||
2056, | ||
2159, | ||
2262, | ||
2365, | ||
2468, | ||
2571, | ||
2675, | ||
2778, | ||
2881, | ||
2984, | ||
3087, | ||
3190, | ||
3293, | ||
3396 | ||
], | ||
0.6 | ||
], | ||
[ | ||
"delay", | ||
[ | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"1/32", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16", | ||
"3/16" | ||
], | ||
"1/8", | ||
0.8 | ||
] | ||
], | ||
"name": [ | ||
"syn" | ||
], | ||
"slide": [ | ||
[ | ||
[ | ||
100, | ||
0 | ||
], | ||
0, | ||
0 | ||
] | ||
] | ||
} | ||
} | ||
}, | ||
"groups": { | ||
"all": [ | ||
"syn" | ||
] | ||
], | ||
}, | ||
"print": [], | ||
"comments": [ | ||
"//silence" | ||
"// combine multiple effects modulated in time by lists", | ||
"// to create interesting synthesized sounds", | ||
"// modulate the length of the note with a cosine function", | ||
"// randomnes to the slide between notes and the overdrive fx", | ||
"// slowly rise the filter cutoff frequency", | ||
"// change delaytimes every 16 notes" | ||
] | ||
@@ -99,29 +317,105 @@ }, | ||
{ | ||
"@list": { | ||
"@name": "str", | ||
"@params": { | ||
"@function": { | ||
"@name": "stretch", | ||
"@args": [ | ||
{ | ||
"@array": [ | ||
"@global": { | ||
"@comment": "// combine multiple effects modulated in time by lists" | ||
} | ||
}, | ||
{ | ||
"@global": { | ||
"@comment": "// to create interesting synthesized sounds" | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "tempo", | ||
"@functions": [ | ||
{ | ||
"@number": 132 | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "crossFade", | ||
"@functions": [ | ||
{ | ||
"@number": 1000 | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "scale", | ||
"@functions": [ | ||
{ | ||
"@identifier": "minor" | ||
}, | ||
{ | ||
"@note": "c" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@new": { | ||
"@inst": "synth", | ||
"@type": { | ||
"@identifier": "saw" | ||
}, | ||
"@functions": [ | ||
{ | ||
"@function": { | ||
"@name": "note", | ||
"@args": [ | ||
{ | ||
"@number": 1 | ||
"@array": [ | ||
{ | ||
"@number": 0 | ||
}, | ||
{ | ||
"@number": 1 | ||
}, | ||
{ | ||
"@array": [ | ||
{ | ||
"@number": 12 | ||
}, | ||
{ | ||
"@number": 24 | ||
}, | ||
{ | ||
"@number": 19 | ||
}, | ||
{ | ||
"@number": 36 | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"@number": 2 | ||
}, | ||
"@number": 0 | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@function": { | ||
"@name": "name", | ||
"@args": [ | ||
{ | ||
"@number": 3 | ||
}, | ||
{ | ||
"@number": 4 | ||
"@identifier": "syn" | ||
} | ||
] | ||
}, | ||
{ | ||
"@number": 10 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
@@ -131,10 +425,15 @@ } | ||
{ | ||
"@list": { | ||
"@name": "str2", | ||
"@params": { | ||
"@function": { | ||
"@name": "stretchFloat", | ||
"@args": [ | ||
{ | ||
"@array": [ | ||
"@global": { | ||
"@comment": "// modulate the length of the note with a cosine function" | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "syn", | ||
"@functions": [ | ||
{ | ||
"@function": { | ||
"@name": "env", | ||
"@args": [ | ||
{ | ||
@@ -144,17 +443,34 @@ "@number": 1 | ||
{ | ||
"@number": 2 | ||
}, | ||
"@function": { | ||
"@name": "cosine", | ||
"@args": [ | ||
{ | ||
"@number": 128 | ||
}, | ||
{ | ||
"@number": 3.14 | ||
}, | ||
{ | ||
"@number": 50 | ||
}, | ||
{ | ||
"@number": 300 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@function": { | ||
"@name": "time", | ||
"@args": [ | ||
{ | ||
"@number": 3 | ||
}, | ||
{ | ||
"@number": 4 | ||
"@division": "1/16" | ||
} | ||
] | ||
}, | ||
{ | ||
"@number": 10 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
@@ -164,29 +480,65 @@ } | ||
{ | ||
"@list": { | ||
"@name": "str3", | ||
"@params": { | ||
"@function": { | ||
"@name": "stretchF", | ||
"@args": [ | ||
{ | ||
"@array": [ | ||
"@global": { | ||
"@comment": "// randomnes to the slide between notes and the overdrive fx" | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "syn", | ||
"@functions": [ | ||
{ | ||
"@function": { | ||
"@name": "slide", | ||
"@args": [ | ||
{ | ||
"@number": 1 | ||
}, | ||
"@array": [ | ||
{ | ||
"@array": [ | ||
{ | ||
"@number": 100 | ||
}, | ||
{ | ||
"@number": 0 | ||
} | ||
] | ||
}, | ||
{ | ||
"@number": 0 | ||
}, | ||
{ | ||
"@number": 0 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@function": { | ||
"@name": "add_fx", | ||
"@args": [ | ||
{ | ||
"@number": 2 | ||
"@identifier": "drive" | ||
}, | ||
{ | ||
"@number": 3 | ||
}, | ||
{ | ||
"@number": 4 | ||
"@function": { | ||
"@name": "random", | ||
"@args": [ | ||
{ | ||
"@number": 4 | ||
}, | ||
{ | ||
"@number": 2 | ||
}, | ||
{ | ||
"@number": 15 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"@number": 10 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
@@ -196,67 +548,96 @@ } | ||
{ | ||
"@list": { | ||
"@name": "str4", | ||
"@params": { | ||
"@function": { | ||
"@name": "lace", | ||
"@args": [ | ||
{ | ||
"@array": [ | ||
"@global": { | ||
"@comment": "// slowly rise the filter cutoff frequency" | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "syn", | ||
"@functions": [ | ||
{ | ||
"@function": { | ||
"@name": "add_fx", | ||
"@args": [ | ||
{ | ||
"@number": 1 | ||
"@identifier": "filter" | ||
}, | ||
{ | ||
"@number": 2 | ||
"@identifier": "low" | ||
}, | ||
{ | ||
"@number": 3 | ||
"@function": { | ||
"@name": "spread", | ||
"@args": [ | ||
{ | ||
"@number": 32 | ||
}, | ||
{ | ||
"@number": 200 | ||
}, | ||
{ | ||
"@number": 3500 | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@number": 4 | ||
"@number": 0.6 | ||
} | ||
] | ||
}, | ||
{ | ||
"@array": [ | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"@global": { | ||
"@comment": "// change delaytimes every 16 notes" | ||
} | ||
}, | ||
{ | ||
"@object": { | ||
"@set": { | ||
"@name": "syn", | ||
"@functions": [ | ||
{ | ||
"@function": { | ||
"@name": "add_fx", | ||
"@args": [ | ||
{ | ||
"@number": 4 | ||
"@identifier": "delay" | ||
}, | ||
{ | ||
"@number": 3 | ||
"@function": { | ||
"@name": "repeat", | ||
"@args": [ | ||
{ | ||
"@array": [ | ||
{ | ||
"@division": "1/32" | ||
}, | ||
{ | ||
"@division": "3/16" | ||
} | ||
] | ||
}, | ||
{ | ||
"@number": 16 | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@number": 2 | ||
"@division": "1/8" | ||
}, | ||
{ | ||
"@number": 1 | ||
"@number": 0.8 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"@global": { | ||
"@print": [ | ||
{ | ||
"@identifier": "str" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@global": { | ||
"@print": [ | ||
{ | ||
"@identifier": "str4" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"@global": { | ||
"@comment": "//silence" | ||
} | ||
} | ||
@@ -263,0 +644,0 @@ ] |
@@ -192,3 +192,3 @@ { | ||
"objects": { | ||
"S1IEQZB4": { | ||
"LRWTWWLC": { | ||
"object": "synth", | ||
@@ -222,7 +222,7 @@ "type": "saw", | ||
"name": [ | ||
"S1IEQZB4" | ||
"LRWTWWLC" | ||
] | ||
} | ||
}, | ||
"9ZRM1PS6": { | ||
"ZAOXZRUR": { | ||
"object": "sample", | ||
@@ -255,7 +255,7 @@ "type": "hat_min", | ||
"name": [ | ||
"9ZRM1PS6" | ||
"ZAOXZRUR" | ||
] | ||
} | ||
}, | ||
"PQ32OMV6": { | ||
"YVX6B459": { | ||
"object": "sample", | ||
@@ -293,7 +293,7 @@ "type": [ | ||
"name": [ | ||
"PQ32OMV6" | ||
"YVX6B459" | ||
] | ||
} | ||
}, | ||
"6VR13K63": { | ||
"A3M3B8W4": { | ||
"object": "synth", | ||
@@ -330,3 +330,3 @@ "type": [ | ||
"name": [ | ||
"6VR13K63" | ||
"A3M3B8W4" | ||
] | ||
@@ -333,0 +333,0 @@ } |
@@ -35,3 +35,3 @@ { | ||
"objects": { | ||
"56XRI962": { | ||
"7ZW1CEYO": { | ||
"object": "synth", | ||
@@ -90,3 +90,3 @@ "type": "saw", | ||
"name": [ | ||
"56XRI962" | ||
"7ZW1CEYO" | ||
] | ||
@@ -150,3 +150,3 @@ } | ||
}, | ||
"B3PRIDRT": { | ||
"TJ95SJ26": { | ||
"object": "sample", | ||
@@ -186,3 +186,3 @@ "type": "violin_g", | ||
"name": [ | ||
"B3PRIDRT" | ||
"TJ95SJ26" | ||
] | ||
@@ -189,0 +189,0 @@ } |
@@ -40,3 +40,3 @@ { | ||
"objects": { | ||
"TW0WZFUF": { | ||
"Q4XCH0M8": { | ||
"object": "sample", | ||
@@ -77,3 +77,3 @@ "type": [ | ||
"name": [ | ||
"TW0WZFUF" | ||
"Q4XCH0M8" | ||
] | ||
@@ -80,0 +80,0 @@ } |
@@ -91,3 +91,3 @@ { | ||
"objects": { | ||
"BNEFTDPV": { | ||
"FVY4VFIK": { | ||
"object": "synth", | ||
@@ -147,7 +147,7 @@ "type": [ | ||
"name": [ | ||
"BNEFTDPV" | ||
"FVY4VFIK" | ||
] | ||
} | ||
}, | ||
"9034EJIG": { | ||
"4SBDMVZ7": { | ||
"object": "sample", | ||
@@ -194,3 +194,3 @@ "type": [ | ||
"name": [ | ||
"9034EJIG" | ||
"4SBDMVZ7" | ||
] | ||
@@ -197,0 +197,0 @@ } |
Sorry, the diff of this file is too big to display
2440611
17846