[Cs-dev] CS6: Grammar Change Brainstorm
Date | 2012-11-09 21:45 |
From | Steven Yi |
Subject | [Cs-dev] CS6: Grammar Change Brainstorm |
Attachments | None None |
Hi All, I was looking into implementing generic arrays (arrays of any type) to replace t-vars. Looking at the grammar, it seems to me that we can simplify the grammar and remove things like T_IDENT_I, T_IDENT_K, etc. and just use T_IDENT. Essentially, it would make the grammar more generic for parsing, and it would move type checking out to a later phase. So, the parsing phase would allow:
fsig oscil fsig2, fsig[45], 123, a234 as it would would be valid for having identifierList-opcode-identifierList; type checking and validation phases would then catch this as an error due to invalid types for oscil.
I took a look at a C grammar and Java grammar for some inspirations: Also, I think we might be able to simply label in the grammar if we only make label be "label:". We use label for goto in the grammar, but I think we could just have it accept "goto T_IDENT". Then in the checking, it could do a lookup of labels with that identifier to see if it exists.
Anyways, thought I'd mention that I'm in this area of code and will be looking into restructuring some things in the grammar. I'm also going to do some analysis on the parser/compiler stages so that things are more clear, i.e. there's type checking only in a single function.
Thanks! steven
|
Date | 2012-11-13 18:10 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Attachments | None None |
Hi Steven, Keep us posted on the changes to support this. I would personally love to see automatic expansion of arrays into parallel opcodes, so you can instantiate multiple oscillators from an array. The output would naturally need to be an array. I think this would also be a great addition to parcs as this is guaranteed to be parallelizable. Cheers, On Nov 9, 2012 1:45 PM, "Steven Yi" <stevenyi@gmail.com> wrote:
Hi All, |
Date | 2012-11-15 01:02 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Hi, Thinking about this, the array grammar should do expansion only if the opcode argument is not itself an a array, that way you could have an opcode like: asig oscilarr 0.5, 440, 0, Array where array is the wavetable for the oscillator. However, if you do: asig oscilarr 0.5, Afreqs, 0, Array Then you would have several parallel oscillators with the frequencies stored in Afreqs oscillating with the wavetable stored in Array. Cheers, Andrés On Fri, Nov 9, 2012 at 1:45 PM, Steven Yi |
Date | 2012-11-15 01:11 |
From | Justin Smith |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Attachments | None None |
If I'm the only one that feels this way, feel free to ignore this, but I found automatic array expansion one of the biggest sources of unexpected and erroneous behavior when I was using SuperCollider, and I would actually prefer that this feature not be present in csound. On Wed, Nov 14, 2012 at 5:02 PM, Andres Cabrera <mantaraya36@gmail.com> wrote: Hi, |
Date | 2012-11-15 01:19 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Hi, I think this is an interesting opinion. Can you elaborate on the kind of problems it created? I think that because Csound is more strongly type that SC, this would not be a problem as the parser would force the right types at the output: asig oscil 0.5, Afreqs, 0 will produce a type error, as the output must be an array. However, another option would be to make automatic expansion optional and disabled by default. So Asigs oscil 0.5, Afreqs, 0 would produce an error, but: Asigs oscil 0.5, ||Afreqs, 0 will do the array expansion into parallel instances of the opcode. (I'm not sure about this notation, but that's the idea...) Cheers, Andrés On Wed, Nov 14, 2012 at 5:11 PM, Justin Smith |
Date | 2012-11-15 15:06 |
From | Justin Smith |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Attachments | None None |
the problems happen when you integrate another cs6 feature, opcodes as inline function calls let's say you can do the following, as in your example: asigs oscil 0.5, afreqs, 0
furthermore, we can distort a signal inline, as follows: asig distort oscil(0.5, kfreq, 0), 500 when we combine these, should it look like this: asig distort oscil(0.5 Afreqs, 0), 500 where we summing all the oscillators before the distortion, or afterward? (distortion is nonlinear, and the two results will sound very different)
or should it look like this: Asigs distort oscil(0.5, Afreqs, 0), 500 where we distort each one in parallel? if this were an argument to another function, say a reverb:
aout nreverb distort(oscil(0.5, Afreqs, 0), 500), 10, 0.3 now we don't even have the explicit requested out type to decide which behavior is desired - is the sum of the signals before or after the distortion?
this is a trivial and easy to read example, but as you start doing more and more inline, and do more automatic expansion, you end up with odd semantic corners of the language, and bugs caused by unintuitive interpretations of seemingly straightforward code
On Wed, Nov 14, 2012 at 5:19 PM, Andres Cabrera <mantaraya36@gmail.com> wrote: Hi, |
Date | 2012-11-15 21:32 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Attachments | None None |
Thanks for elaborating. I think csound's strong typing is an advantage here, as: Would produce a syntax error because the output has to be an array of audio signals. So there is automatic expansion, but not automatic mix down to avoid these issues. Do you think this would be enough? I have also proposed typed arrays, whose contents must be of a particular type, to help enforce type checking. See: http://sourceforge.net/apps/mediawiki/csound/index.php?title=RFC_1-Arrays Cheers, On Nov 15, 2012 7:07 AM, "Justin Smith" <noisesmith@gmail.com> wrote:
the problems happen when you integrate another cs6 feature, opcodes as inline function calls |
Date | 2012-11-15 22:42 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CS6: Grammar Change Brainstorm |
Attachments | None None |
That is actually starting to look promising. On 15 Nov 2012, at 21:32, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |