Blueberry icon indicating copy to clipboard operation
Blueberry copied to clipboard

Lack of support for arbitrary lvalues, no `foo.bar` or `foo[bar]`

Open hikari-no-yume opened this issue 10 years ago • 6 comments

foo[:bar] = 3 doesn't work, nor does foo.bar. Also, no nesting is possible, so foo.bar[:bang].boo doesn't work, which also doesn't work on the right-hand side, too.

hikari-no-yume avatar Nov 17 '14 17:11 hikari-no-yume

Looks like assignment rule is not defined for arrays! Interesting.

gosukiwi avatar Nov 17 '14 19:11 gosukiwi

You seemed to have deliberately commented out the test for that:

https://github.com/gosukiwi/Blueberry/blob/master/tests/test.js#L151

And if you're going to fix the nesting thing, you should do that by making the rule recursive.

hikari-no-yume avatar Nov 17 '14 19:11 hikari-no-yume

Well there are several things to fix on the grammar I think, mostly for expressions. If I make chaining work, it will be with recursion :smile:

Right now you can do myVar = a.b.c().d I just have to put array expressions into the mix.

gosukiwi avatar Nov 17 '14 20:11 gosukiwi

One fun thing is that PHP 5 (unlike PHP 7) doesn't have arbitrarily-nestable lvalues or rvalues... so some things that Blueberry supports might not be supported in PHP 5 without adding brackets or temporary variables ^^

hikari-no-yume avatar Nov 17 '14 20:11 hikari-no-yume

I worked on this in 2ef5eed87f8f68a881e319353e5ac74cacc06bce I don't think it's finished but it's a start :smile:

RHS values are still limited though, for example, you can't do f()[1] (you can't do it in PHP 5 either)

gosukiwi avatar Nov 18 '14 10:11 gosukiwi

I think PHP 5.6 (or was it 5.4?) fixed that one.

hikari-no-yume avatar Nov 18 '14 11:11 hikari-no-yume