derick
January 16, 2020, 10:41am
1
From the CottleSC3 document, I want to try this example:
(
{
var bufNum = ~b_med1.bufnum, srate = 44100, start = 0, end = 3, duration, rate = 1;
// Use these lines for proportional lengths
// var bufNum = 0, srate = 44100, start = 0.21, end = 0.74,
// rate = 1, duration, total;
// total = BufFrames.kr(bufNum)/44100;
// end = end*total; start = start*total;
duration = abs(end - start);
BufRd.ar(2, bufNum, // Buffer 0
LinLin.ar(
LFSaw.ar(rate/duration, 1), -1, 1, start, end)*srate)*EnvGen.kr(Env.linen(0.01, 0.98, 0.01),
timeScale: duration, gate: Impulse.kr(1/duration));
}.play
)
But I get this error and can’t find the problem:
ERROR: syntax error, unexpected $end, expecting ')'
in file 'selected text'
line 1 char 3:
(
-----------------------------------
ERROR: Command line parse failed
-> nil
derick
January 16, 2020, 12:12pm
2
It looks like running the code fails on my system when a file exceeds a certain amount of lines (300 now)… ?
When I paste the code in a new file, it works as expected.
That certainly can’t be it. I’ve got files of a few thousand lines.
There is a known issue where a syntax error on, say, line 100 will cause the IDE to fail to see any (...)
regions after it (even if you aren’t running the code containing the syntax error). I would guess that’s what you’re seeing.
opened 07:29PM - 12 Mar 16 UTC
bug
env: SCIDE
Here the reproducer for the bug in the parser:
```
(
1+1; // put the cursor int… o this line and press Cmd-Return => you get 3, press Shift-Return => you get 2 (All as expected)
1+2;
)
{ Saw.ar(LFNoise1.kr(1).range(100,[200,300]) }.play;
Above code causes no problems and all works as expected. However, if you reverse the ordering to this:
{ Saw.ar(LFNoise1.kr(1).range(100,[200,300]) }.play;
(
1+1; // put the cursor into this line and press Cmd-Return => you get 2 but should get 3, press Shift-Return => you get 2
1+2;
)
```
You no longer get what you expect, i.e. the parser fails to execute the correct statements within the region as defined by the parantheses. The reason is only the presence of a mistake before/above the region instead of after/below the region. The mistake is in the Saw.ar line, BTW a line taken from the Multichannel-Expansion guide (but now fixed cf. b54e617). But the parser should never get there in the first place, since that faulty line is outside the two parantheses and evaluation should stop at the left paranthesis and not encounter the line of code containing Saw.ar.
I believe the parser should always evaluate correctly everything within a region as defined by parantheses regardless of what is outside of the region.
Note, this issue is a follow up of issue #1786 and has also been partly discussed under #1781, both now closed.
BTW, my guess is also that this bug may explain help browser code execution problems as described in issue #1676. But I have not studied that issue in details. It merely appears to me to be logical that if the parser is context dependent – as above reproducer demonstrates – that parsing may easily fail if a region is embedded in freely written text as is the case with help/tutorial texts.
I believe this issue has nothing to do with a particular system. I have been able to reproduce the bug on several systems and using different versions of SC. The last test was done using SuperCollider 3.7.0-beta1 Built from branch 'HEAD' 9899190 under OS X 10.9.5 (Mavericks).
hjh