Re: Context-Free Grammars? What about arrays?

2011-02-16 Thread %u
Yes, they just happen to look identical: but that's the crux: How it looks is the *only* thing that parser/grammar are concerned with. If it worked like this: Array Decl ::= Type '[' Ident ']' Ident ';' Assoc Array Decl ::= Type '[' Ident ']' Ident ';' ...*Then* it would no longer be

Re: Context-Free Grammars? What about arrays?

2011-02-14 Thread Nick Sabalausky
%u wfunct...@hotmail.com wrote in message news:ij3la9$t53$1...@digitalmars.com... The problem is that it _is_ ambiguous what rule to apply. To me, just because static arrays and associative arrays happen to have similar _looks_ doesn't make parsing them context-free -- they're defined

Re: Context-Free Grammars? What about arrays?

2011-02-14 Thread Nick Sabalausky
%u wfunct...@hotmail.com wrote in message news:ij3la9$t53$1...@digitalmars.com... Again, just because the AST's _happen_ to _look_ the same for static and associative arrays, does that mean that this makes D context-free? Grammar is *just* about how it *looks*, not what it means. The

Context-Free Grammars? What about arrays?

2011-02-11 Thread %u
Hi, I think I'm having a little trouble understanding what's meant by context-free grammar. I've read that D is context-free, but is it really? What about an expression like: int[U] s; ? You can't tell -- without looking at the context -- whether U is a data type or a number, and so because

Re: Context-Free Grammars? What about arrays?

2011-02-11 Thread Jonathan M Davis
On Friday 11 February 2011 01:03:21 %u wrote: Hi, I think I'm having a little trouble understanding what's meant by context-free grammar. I've read that D is context-free, but is it really? What about an expression like: int[U] s; ? You can't tell -- without looking at the context --

Re: Context-Free Grammars? What about arrays?

2011-02-11 Thread spir
On 02/11/2011 10:03 AM, %u wrote: Hi, I think I'm having a little trouble understanding what's meant by context-free grammar. I've read that D is context-free, but is it really? What about an expression like: int[U] s; ? You can't tell -- without looking at the context -- whether U is a data

Re: Context-Free Grammars? What about arrays?

2011-02-11 Thread Jonathan M Davis
On Friday 11 February 2011 03:22:54 spir wrote: On 02/11/2011 10:03 AM, %u wrote: Hi, I think I'm having a little trouble understanding what's meant by context-free grammar. I've read that D is context-free, but is it really? What about an expression like: int[U] s; ? You

Re: Context-Free Grammars? What about arrays?

2011-02-11 Thread Ary Manzana
On 2/11/11 6:03 AM, %u wrote: Hi, I think I'm having a little trouble understanding what's meant by context-free grammar. I've read that D is context-free, but is it really? What about an expression like: int[U] s; ? You can't tell -- without looking at the context -- whether U is a data type

Re: Context-Free Grammars? What about arrays?

2011-02-11 Thread %u
That will always parse to an associative array. Then in the semantic pass, if U is a constant expression that turns out to be an integer it is reinterpreted as a static array. Ah, interesting. But that describes the implementation (i.e. how the compiler copes with the ambiguity) and not the

Re: Context-Free Grammars? What about arrays?

2011-02-11 Thread Jacob Carlborg
On 2011-02-11 10:37, Jonathan M Davis wrote: On Friday 11 February 2011 01:03:21 %u wrote: Hi, I think I'm having a little trouble understanding what's meant by context-free grammar. I've read that D is context-free, but is it really? What about an expression like: int[U] s; ? You can't tell