re-fresh
[nedit-bw.git] / ternary-operator.patch
blob2d1c431cafb53f4a046d48389f9b8bdaf4ce9ed8
1 ---
3 source/parse.y | 15 +++++++++++++++
4 1 file changed, 15 insertions(+)
6 diff --quilt old/source/parse.y new/source/parse.y
7 --- old/source/parse.y
8 +++ new/source/parse.y
9 @@ -137,6 +137,7 @@ static int nextSymIsField = 0;
10 %type <num> lvlist
11 %type <inst> lventry
12 %token ARGSEP
13 +%type <inst> thenx elsex
15 %nonassoc IF_NO_ELSE
16 %nonassoc ELSE
17 @@ -144,6 +145,7 @@ static int nextSymIsField = 0;
18 %nonassoc ';'
19 %nonassoc SYMBOL ARG_LOOKUP
20 %right '=' ADDEQ SUBEQ MULEQ DIVEQ MODEQ ANDEQ OREQ
21 +%right '?' ':'
22 %left CONCAT
23 %left OR
24 %left AND
25 @@ -680,6 +682,10 @@ numexpr: '(' blank expr blank ')'
26 | numexpr or blank numexpr %prec OR {
27 ADD_OP(OP_OR); SET_BR_OFF($2, GetPC());
29 + | numexpr thenx blank numexpr elsex blank numexpr %prec '?' {
30 + SET_BR_OFF($2, $5 + 1); /* thenx limb ends at $5+1 */
31 + SET_BR_OFF($5, GetPC()); /* elsex limb ends here */
32 + }
33 | incrdecr blank SYMBOL %prec INCR {
34 ADD_OP(OP_PUSH_SYM); ADD_SYM($3); ADD_OP($1);
35 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM($3);
36 @@ -741,6 +747,15 @@ or: OR {
40 +thenx: '?' {
41 + ADD_OP(OP_BRANCH_FALSE); $$ = GetPC();
42 + ADD_BR_OFF(0);
43 + }
44 +elsex: ':' {
45 + ADD_OP(OP_BRANCH); $$ = GetPC();
46 + ADD_BR_OFF(0);
47 + }
49 dot: '.' %prec '.' {
50 nextSymIsField = 1;