MultipleAssignment selectors
[nedit-bw.git] / MultipleAssignment-selector.patch
blob270495d225079b3299c9152cbbfb2384a5e5c3f0
1 ---
3 source/parse.y | 43 +++++++++++++++++++++++++++++++++++--------
4 1 file changed, 35 insertions(+), 8 deletions(-)
6 diff --quilt old/source/parse.y new/source/parse.y
7 --- old/source/parse.y
8 +++ new/source/parse.y
9 @@ -421,27 +421,54 @@ lvlistexpr: '(' mark lvlist mark ')' bla
10 ** the lvalue, so that the result is ontop od the stack.
11 ** lventry's value will give us the start of this code.
13 -lvlist: lventry {
14 - Inst *this = GetPC();
15 +lvlist: blank {
16 + /* start case and skip this index */
17 + $$ = 1;
18 + }
19 + | lventry mark {
20 /* start case */
21 $$ = 1;
22 /* add code to push the rvalue expression value */
23 ADD_OP(OP_PUSH_IMMED); ADD_IMMED($$);
24 ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
25 /* swap this code in front of the lvalue assignment code */
26 - SwapCode($1, this, GetPC());
27 + SwapCode($1, $2, GetPC());
28 + }
29 + | lventry mark lvselector {
30 + /* don't advance index */
31 + $$ = 0;
32 + /* swap this code in front of the lvalue assignment code */
33 + SwapCode($1, $2, GetPC());
35 - | lvlist ',' blank lventry {
36 - Inst *this = GetPC();
37 + | lvlist ',' blank {
38 + /* skip this index */
39 + $$ = $1 + 1;
40 + }
41 + | lvlist ',' blank lventry mark {
42 /* the index for this entry into the rvalue array */
43 $$ = $1 + 1;
44 /* add code to push the rvalue expression value */
45 ADD_OP(OP_PUSH_IMMED); ADD_IMMED($$);
46 ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
47 /* swap this code in front of the lvalue assignment code */
48 - SwapCode($4, this, GetPC());
49 - }
50 - ;
51 + SwapCode($4, $5, GetPC());
52 + }
53 + | lvlist ',' blank lventry mark lvselector {
54 + /* don't advance index */
55 + $$ = $1 + 0;
56 + /* swap this code in front of the lvalue assignment code */
57 + SwapCode($4, $5, GetPC());
58 + }
59 + ;
60 +lvselector: blank '=' blank '[' arglist ']' {
61 + /* add code to push the rvalue expression value */
62 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($5);
63 + }
64 + | blank '=' blank dot field {
65 + /* add code to push the rvalue expression value */
66 + ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
67 + }
68 + ;
69 /* lventry's value is the start of the assignment code */
70 lventry: SYMBOL {
71 /* the rvalue is right on top, just dup it */