]> git.sur5r.net Git - i3/i3/blob - src/cmdparse.y
Merge i3bar into next
[i3/i3] / src / cmdparse.y
1 %{
2 /*
3  * vim:ts=4:sw=4:expandtab
4  *
5  * i3 - an improved dynamic tiling window manager
6  * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
7  *
8  * cmdparse.y: the parser for commands you send to i3 (or bind on keys)
9  *
10
11  */
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <unistd.h>
15 #include <fcntl.h>
16 #include <limits.h>
17
18 #include "all.h"
19
20 /** When the command did not include match criteria (!), we use the currently
21  * focused command. Do not confuse this case with a command which included
22  * criteria but which did not match any windows. This macro has to be called in
23  * every command.
24  */
25 #define HANDLE_EMPTY_MATCH do { \
26     if (match_is_empty(&current_match)) { \
27         owindow *ow = smalloc(sizeof(owindow)); \
28         ow->con = focused; \
29         TAILQ_INIT(&owindows); \
30         TAILQ_INSERT_TAIL(&owindows, ow, owindows); \
31     } \
32 } while (0)
33
34 typedef struct yy_buffer_state *YY_BUFFER_STATE;
35 extern int cmdyylex(struct context *context);
36 extern int cmdyyparse(void);
37 extern int cmdyylex_destroy(void);
38 extern FILE *cmdyyin;
39 YY_BUFFER_STATE cmdyy_scan_string(const char *);
40
41 static struct context *context;
42 static Match current_match;
43
44 /*
45  * Helper data structure for an operation window (window on which the operation
46  * will be performed). Used to build the TAILQ owindows.
47  *
48  */
49 typedef struct owindow {
50     Con *con;
51     TAILQ_ENTRY(owindow) owindows;
52 } owindow;
53 static TAILQ_HEAD(owindows_head, owindow) owindows;
54
55 /* Holds the JSON which will be returned via IPC or NULL for the default return
56  * message */
57 static char *json_output;
58
59 /* We don’t need yydebug for now, as we got decent error messages using
60  * yyerror(). Should you ever want to extend the parser, it might be handy
61  * to just comment it in again, so it stays here. */
62 //int cmdyydebug = 1;
63
64 void cmdyyerror(const char *error_message) {
65     ELOG("\n");
66     ELOG("CMD: %s\n", error_message);
67     ELOG("CMD: in command:\n");
68     ELOG("CMD:   %s\n", context->line_copy);
69     ELOG("CMD:   ");
70     for (int c = 1; c <= context->last_column; c++)
71         if (c >= context->first_column)
72                 printf("^");
73         else printf(" ");
74     printf("\n");
75     ELOG("\n");
76     context->compact_error = sstrdup(error_message);
77 }
78
79 int cmdyywrap() {
80     return 1;
81 }
82
83 char *parse_cmd(const char *new) {
84     LOG("COMMAND: *%s*\n", new);
85     cmdyy_scan_string(new);
86
87     match_init(&current_match);
88     context = scalloc(sizeof(struct context));
89     context->filename = "cmd";
90     FREE(json_output);
91     if (cmdyyparse() != 0) {
92         fprintf(stderr, "Could not parse command\n");
93         asprintf(&json_output, "{\"success\":false, \"error\":\"%s at position %d\"}",
94                  context->compact_error, context->first_column);
95         FREE(context->line_copy);
96         FREE(context->compact_error);
97         free(context);
98         return json_output;
99     }
100     printf("done, json output = %s\n", json_output);
101
102     cmdyylex_destroy();
103     FREE(context->line_copy);
104     FREE(context->compact_error);
105     free(context);
106     return json_output;
107 }
108
109 %}
110
111 %error-verbose
112 %lex-param { struct context *context }
113
114 %union {
115     char *string;
116     char chr;
117     int number;
118 }
119
120 %token              TOK_EXEC            "exec"
121 %token              TOK_EXIT            "exit"
122 %token              TOK_RELOAD          "reload"
123 %token              TOK_RESTART         "restart"
124 %token              TOK_KILL            "kill"
125 %token              TOK_WINDOW          "window"
126 %token              TOK_CLIENT          "client"
127 %token              TOK_FULLSCREEN      "fullscreen"
128 %token              TOK_GLOBAL          "global"
129 %token              TOK_LAYOUT          "layout"
130 %token              TOK_DEFAULT         "default"
131 %token              TOK_STACKED         "stacked"
132 %token              TOK_TABBED          "tabbed"
133 %token              TOK_BORDER          "border"
134 %token              TOK_NORMAL          "normal"
135 %token              TOK_NONE            "none"
136 %token              TOK_1PIXEL          "1pixel"
137 %token              TOK_MODE            "mode"
138 %token              TOK_TILING          "tiling"
139 %token              TOK_FLOATING        "floating"
140 %token              TOK_MODE_TOGGLE     "mode_toggle"
141 %token              TOK_ENABLE          "enable"
142 %token              TOK_DISABLE         "disable"
143 %token              TOK_WORKSPACE       "workspace"
144 %token              TOK_TOGGLE          "toggle"
145 %token              TOK_FOCUS           "focus"
146 %token              TOK_MOVE            "move"
147 %token              TOK_OPEN            "open"
148 %token              TOK_NEXT            "next"
149 %token              TOK_PREV            "prev"
150 %token              TOK_SPLIT           "split"
151 %token              TOK_HORIZONTAL      "horizontal"
152 %token              TOK_VERTICAL        "vertical"
153 %token              TOK_UP              "up"
154 %token              TOK_DOWN            "down"
155 %token              TOK_LEFT            "left"
156 %token              TOK_RIGHT           "right"
157 %token              TOK_PARENT          "parent"
158 %token              TOK_CHILD           "child"
159 %token              TOK_APPEND_LAYOUT   "append_layout"
160 %token              TOK_MARK            "mark"
161 %token              TOK_RESIZE          "resize"
162 %token              TOK_GROW            "grow"
163 %token              TOK_SHRINK          "shrink"
164 %token              TOK_PX              "px"
165 %token              TOK_OR              "or"
166 %token              TOK_PPT             "ppt"
167 %token              TOK_NOP             "nop"
168
169 %token              TOK_CLASS           "class"
170 %token              TOK_ID              "id"
171 %token              TOK_CON_ID          "con_id"
172 %token              TOK_TITLE           "title"
173
174 %token  <string>    STR                 "<string>"
175 %token  <number>    NUMBER              "<number>"
176
177 %type   <number>    direction
178 %type   <number>    split_direction
179 %type   <number>    fullscreen_mode
180 %type   <number>    level
181 %type   <number>    window_mode
182 %type   <number>    boolean
183 %type   <number>    border_style
184 %type   <number>    layout_mode
185 %type   <number>    resize_px
186 %type   <number>    resize_way
187 %type   <number>    resize_tiling
188 %type   <number>    optional_kill_mode
189
190 %%
191
192 commands:
193     commands ';' command
194     | command
195     {
196         owindow *current;
197
198         printf("single command completely parsed, dropping state...\n");
199         while (!TAILQ_EMPTY(&owindows)) {
200             current = TAILQ_FIRST(&owindows);
201             TAILQ_REMOVE(&owindows, current, owindows);
202             free(current);
203         }
204         match_init(&current_match);
205     }
206     ;
207
208 command:
209     match operations
210     ;
211
212 match:
213     | matchstart criteria matchend
214     {
215         printf("match parsed\n");
216     }
217     ;
218
219 matchstart:
220     '['
221     {
222         printf("start\n");
223         match_init(&current_match);
224         TAILQ_INIT(&owindows);
225         /* copy all_cons */
226         Con *con;
227         TAILQ_FOREACH(con, &all_cons, all_cons) {
228             owindow *ow = smalloc(sizeof(owindow));
229             ow->con = con;
230             TAILQ_INSERT_TAIL(&owindows, ow, owindows);
231         }
232     }
233     ;
234
235 matchend:
236     ']'
237     {
238         owindow *next, *current;
239
240         printf("match specification finished, matching...\n");
241         /* copy the old list head to iterate through it and start with a fresh
242          * list which will contain only matching windows */
243         struct owindows_head old = owindows;
244         TAILQ_INIT(&owindows);
245         for (next = TAILQ_FIRST(&old); next != TAILQ_END(&old);) {
246             /* make a copy of the next pointer and advance the pointer to the
247              * next element as we are going to invalidate the element’s
248              * next/prev pointers by calling TAILQ_INSERT_TAIL later */
249             current = next;
250             next = TAILQ_NEXT(next, owindows);
251
252             printf("checking if con %p / %s matches\n", current->con, current->con->name);
253             if (current_match.con_id != NULL) {
254                 if (current_match.con_id == current->con) {
255                     printf("matches container!\n");
256                     TAILQ_INSERT_TAIL(&owindows, current, owindows);
257
258                 }
259             } else if (current_match.mark != NULL && current->con->mark != NULL &&
260                     strcasecmp(current_match.mark, current->con->mark) == 0) {
261                 printf("match by mark\n");
262                     TAILQ_INSERT_TAIL(&owindows, current, owindows);
263
264             } else {
265                 if (current->con->window == NULL)
266                     continue;
267                 if (match_matches_window(&current_match, current->con->window)) {
268                     printf("matches window!\n");
269                     TAILQ_INSERT_TAIL(&owindows, current, owindows);
270                 } else {
271                     printf("doesnt match\n");
272                     free(current);
273                 }
274             }
275         }
276
277         TAILQ_FOREACH(current, &owindows, owindows) {
278             printf("matching: %p / %s\n", current->con, current->con->name);
279         }
280
281     }
282     ;
283
284 criteria:
285     criteria criterion
286     | criterion
287     ;
288
289 criterion:
290     TOK_CLASS '=' STR
291     {
292         printf("criteria: class = %s\n", $3);
293         current_match.class = $3;
294     }
295     | TOK_CON_ID '=' STR
296     {
297         printf("criteria: id = %s\n", $3);
298         char *end;
299         long parsed = strtol($3, &end, 10);
300         if (parsed == LONG_MIN ||
301             parsed == LONG_MAX ||
302             parsed < 0 ||
303             (end && *end != '\0')) {
304             ELOG("Could not parse con id \"%s\"\n", $3);
305         } else {
306             current_match.con_id = (Con*)parsed;
307             printf("id as int = %p\n", current_match.con_id);
308         }
309     }
310     | TOK_ID '=' STR
311     {
312         printf("criteria: window id = %s\n", $3);
313         char *end;
314         long parsed = strtol($3, &end, 10);
315         if (parsed == LONG_MIN ||
316             parsed == LONG_MAX ||
317             parsed < 0 ||
318             (end && *end != '\0')) {
319             ELOG("Could not parse window id \"%s\"\n", $3);
320         } else {
321             current_match.id = parsed;
322             printf("window id as int = %d\n", current_match.id);
323         }
324     }
325     | TOK_MARK '=' STR
326     {
327         printf("criteria: mark = %s\n", $3);
328         current_match.mark = $3;
329     }
330     | TOK_TITLE '=' STR
331     {
332         printf("criteria: title = %s\n", $3);
333         current_match.title = $3;
334     }
335     ;
336
337 operations:
338     operation
339     | operations ',' operation
340     ;
341
342 operation:
343     exec
344     | exit
345     | restart
346     | reload
347     | border
348     | layout
349     | append_layout
350     | move
351     | workspace
352     | focus
353     | kill
354     | open
355     | fullscreen
356     | split
357     | floating
358     | mark
359     | resize
360     | nop
361     | mode
362     ;
363
364 exec:
365     TOK_EXEC STR
366     {
367         printf("should execute %s\n", $2);
368         start_application($2);
369         free($2);
370     }
371     ;
372
373 exit:
374     TOK_EXIT
375     {
376         printf("exit, bye bye\n");
377         exit(0);
378     }
379     ;
380
381 reload:
382     TOK_RELOAD
383     {
384         printf("reloading\n");
385         kill_configerror_nagbar(false);
386         load_configuration(conn, NULL, true);
387         x_set_i3_atoms();
388         /* Send an IPC event just in case the ws names have changed */
389         ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"reload\"}");
390     }
391     ;
392
393 restart:
394     TOK_RESTART
395     {
396         printf("restarting i3\n");
397         i3_restart(false);
398     }
399     ;
400
401 focus:
402     TOK_FOCUS
403     {
404         owindow *current;
405
406         if (match_is_empty(&current_match)) {
407             ELOG("You have to specify which window/container should be focused.\n");
408             ELOG("Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
409
410             asprintf(&json_output, "{\"success\":false, \"error\":\"You have to "
411                      "specify which window/container should be focused\"}");
412             break;
413         }
414
415         int count = 0;
416         TAILQ_FOREACH(current, &owindows, owindows) {
417             Con *ws = con_get_workspace(current->con);
418             workspace_show(ws->name);
419             LOG("focusing %p / %s\n", current->con, current->con->name);
420             con_focus(current->con);
421             count++;
422         }
423
424         if (count > 1)
425             LOG("WARNING: Your criteria for the focus command matches %d containers, "
426                 "while only exactly one container can be focused at a time.\n", count);
427
428         tree_render();
429     }
430     | TOK_FOCUS direction
431     {
432         int direction = $2;
433         switch (direction) {
434             case TOK_LEFT:
435                 LOG("Focusing left\n");
436                 tree_next('p', HORIZ);
437                 break;
438             case TOK_RIGHT:
439                 LOG("Focusing right\n");
440                 tree_next('n', HORIZ);
441                 break;
442             case TOK_UP:
443                 LOG("Focusing up\n");
444                 tree_next('p', VERT);
445                 break;
446             case TOK_DOWN:
447                 LOG("Focusing down\n");
448                 tree_next('n', VERT);
449                 break;
450             default:
451                 ELOG("Invalid focus direction (%d)\n", direction);
452                 break;
453         }
454
455         tree_render();
456     }
457     | TOK_FOCUS window_mode
458     {
459         printf("should focus: ");
460
461         if ($2 == TOK_TILING)
462             printf("tiling\n");
463         else if ($2 == TOK_FLOATING)
464             printf("floating\n");
465         else printf("mode toggle\n");
466
467         Con *ws = con_get_workspace(focused);
468         Con *current;
469         if (ws != NULL) {
470             int to_focus = $2;
471             if ($2 == TOK_MODE_TOGGLE) {
472                 current = TAILQ_FIRST(&(ws->focus_head));
473                 if (current->type == CT_FLOATING_CON)
474                     to_focus = TOK_TILING;
475                 else to_focus = TOK_FLOATING;
476             }
477             TAILQ_FOREACH(current, &(ws->focus_head), focused) {
478                 if ((to_focus == TOK_FLOATING && current->type != CT_FLOATING_CON) ||
479                     (to_focus == TOK_TILING && current->type == CT_FLOATING_CON))
480                     continue;
481
482                 con_focus(con_descend_focused(current));
483                 break;
484             }
485         }
486
487         tree_render();
488     }
489     | TOK_FOCUS level
490     {
491         if ($2 == TOK_PARENT)
492             level_up();
493         else level_down();
494
495         tree_render();
496     }
497     ;
498
499 window_mode:
500     TOK_TILING        { $$ = TOK_TILING; }
501     | TOK_FLOATING    { $$ = TOK_FLOATING; }
502     | TOK_MODE_TOGGLE { $$ = TOK_MODE_TOGGLE; }
503     ;
504
505 level:
506     TOK_PARENT  { $$ = TOK_PARENT; }
507     | TOK_CHILD { $$ = TOK_CHILD;  }
508     ;
509
510 kill:
511     TOK_KILL optional_kill_mode
512     {
513         owindow *current;
514
515         printf("killing!\n");
516         /* check if the match is empty, not if the result is empty */
517         if (match_is_empty(&current_match))
518             tree_close_con($2);
519         else {
520             TAILQ_FOREACH(current, &owindows, owindows) {
521                 printf("matching: %p / %s\n", current->con, current->con->name);
522                 tree_close(current->con, $2, false);
523             }
524         }
525
526         tree_render();
527     }
528     ;
529
530 optional_kill_mode:
531     /* empty */             { $$ = KILL_WINDOW; }
532     | TOK_WINDOW { $$ = KILL_WINDOW; }
533     | TOK_CLIENT { $$ = KILL_CLIENT; }
534     ;
535
536 workspace:
537     TOK_WORKSPACE TOK_NEXT
538     {
539         workspace_next();
540         tree_render();
541     }
542     | TOK_WORKSPACE TOK_PREV
543     {
544         workspace_prev();
545         tree_render();
546     }
547     | TOK_WORKSPACE STR
548     {
549         printf("should switch to workspace %s\n", $2);
550         workspace_show($2);
551         free($2);
552
553         tree_render();
554     }
555     ;
556
557 open:
558     TOK_OPEN
559     {
560         printf("opening new container\n");
561         Con *con = tree_open_con(NULL, NULL);
562         con_focus(con);
563         asprintf(&json_output, "{\"success\":true, \"id\":%ld}", (long int)con);
564
565         tree_render();
566     }
567     ;
568
569 fullscreen:
570     TOK_FULLSCREEN fullscreen_mode
571     {
572         printf("toggling fullscreen, mode = %s\n", ($2 == CF_OUTPUT ? "normal" : "global"));
573         owindow *current;
574
575         HANDLE_EMPTY_MATCH;
576
577         TAILQ_FOREACH(current, &owindows, owindows) {
578             printf("matching: %p / %s\n", current->con, current->con->name);
579             con_toggle_fullscreen(current->con, $2);
580         }
581
582         tree_render();
583     }
584     ;
585
586 fullscreen_mode:
587     /* empty */  { $$ = CF_OUTPUT; }
588     | TOK_GLOBAL { $$ = CF_GLOBAL; }
589     ;
590
591 split:
592     TOK_SPLIT split_direction
593     {
594         /* TODO: use matches */
595         printf("splitting in direction %c\n", $2);
596         tree_split(focused, ($2 == 'v' ? VERT : HORIZ));
597
598         tree_render();
599     }
600     ;
601
602 split_direction:
603     TOK_HORIZONTAL  { $$ = 'h'; }
604     | 'h'           { $$ = 'h'; }
605     | TOK_VERTICAL  { $$ = 'v'; }
606     | 'v'           { $$ = 'v'; }
607     ;
608
609 floating:
610     TOK_FLOATING boolean
611     {
612         HANDLE_EMPTY_MATCH;
613
614         owindow *current;
615         TAILQ_FOREACH(current, &owindows, owindows) {
616             printf("matching: %p / %s\n", current->con, current->con->name);
617             if ($2 == TOK_TOGGLE) {
618                 printf("should toggle mode\n");
619                 toggle_floating_mode(current->con, false);
620             } else {
621                 printf("should switch mode to %s\n", ($2 == TOK_FLOATING ? "floating" : "tiling"));
622                 if ($2 == TOK_ENABLE) {
623                     floating_enable(current->con, false);
624                 } else {
625                     floating_disable(current->con, false);
626                 }
627             }
628         }
629
630         tree_render();
631     }
632     ;
633
634 boolean:
635     TOK_ENABLE    { $$ = TOK_ENABLE; }
636     | TOK_DISABLE { $$ = TOK_DISABLE; }
637     | TOK_TOGGLE  { $$ = TOK_TOGGLE; }
638     ;
639
640 border:
641     TOK_BORDER border_style
642     {
643         printf("border style should be changed to %d\n", $2);
644         owindow *current;
645
646         HANDLE_EMPTY_MATCH;
647
648         TAILQ_FOREACH(current, &owindows, owindows) {
649             printf("matching: %p / %s\n", current->con, current->con->name);
650             if ($2 == TOK_TOGGLE) {
651                 current->con->border_style++;
652                 current->con->border_style %= 3;
653             } else current->con->border_style = $2;
654         }
655
656         tree_render();
657     }
658     ;
659
660 border_style:
661     TOK_NORMAL      { $$ = BS_NORMAL; }
662     | TOK_NONE      { $$ = BS_NONE; }
663     | TOK_1PIXEL    { $$ = BS_1PIXEL; }
664     | TOK_TOGGLE    { $$ = TOK_TOGGLE; }
665     ;
666
667 move:
668     TOK_MOVE direction
669     {
670         printf("moving in direction %d\n", $2);
671         tree_move($2);
672
673         tree_render();
674     }
675     | TOK_MOVE TOK_WORKSPACE STR
676     {
677         owindow *current;
678
679         printf("should move window to workspace %s\n", $3);
680         /* get the workspace */
681         Con *ws = workspace_get($3, NULL);
682         free($3);
683
684         HANDLE_EMPTY_MATCH;
685
686         TAILQ_FOREACH(current, &owindows, owindows) {
687             printf("matching: %p / %s\n", current->con, current->con->name);
688             con_move_to_workspace(current->con, ws);
689         }
690
691         tree_render();
692     }
693     ;
694
695 append_layout:
696     TOK_APPEND_LAYOUT STR
697     {
698         printf("restoring \"%s\"\n", $2);
699         tree_append_json($2);
700         free($2);
701         tree_render();
702     }
703     ;
704
705 layout:
706     TOK_LAYOUT layout_mode
707     {
708         printf("changing layout to %d\n", $2);
709         owindow *current;
710
711         /* check if the match is empty, not if the result is empty */
712         if (match_is_empty(&current_match))
713             con_set_layout(focused->parent, $2);
714         else {
715             TAILQ_FOREACH(current, &owindows, owindows) {
716                 printf("matching: %p / %s\n", current->con, current->con->name);
717                 con_set_layout(current->con, $2);
718             }
719         }
720
721         tree_render();
722     }
723     ;
724
725 layout_mode:
726     TOK_DEFAULT   { $$ = L_DEFAULT; }
727     | TOK_STACKED { $$ = L_STACKED; }
728     | TOK_TABBED  { $$ = L_TABBED; }
729     ;
730
731 mark:
732     TOK_MARK STR
733     {
734         printf("marking window with str %s\n", $2);
735         owindow *current;
736
737         HANDLE_EMPTY_MATCH;
738
739         TAILQ_FOREACH(current, &owindows, owindows) {
740             printf("matching: %p / %s\n", current->con, current->con->name);
741             current->con->mark = sstrdup($2);
742         }
743
744         free($<string>2);
745
746         tree_render();
747     }
748     ;
749
750 nop:
751     TOK_NOP STR
752     {
753         printf("-------------------------------------------------\n");
754         printf("  NOP: %s\n", $2);
755         printf("-------------------------------------------------\n");
756         free($2);
757     }
758     ;
759
760 resize:
761     TOK_RESIZE resize_way direction resize_px resize_tiling
762     {
763         /* resize <grow|shrink> <direction> [<px> px] [or <ppt> ppt] */
764         printf("resizing in way %d, direction %d, px %d or ppt %d\n", $2, $3, $4, $5);
765         int direction = $3;
766         int px = $4;
767         int ppt = $5;
768         if ($2 == TOK_SHRINK) {
769             px *= -1;
770             ppt *= -1;
771         }
772
773         if (con_is_floating(focused)) {
774             printf("floating resize\n");
775             if (direction == TOK_UP) {
776                 focused->parent->rect.y -= px;
777                 focused->parent->rect.height += px;
778             } else if (direction == TOK_DOWN) {
779                 focused->rect.height += px;
780             } else if (direction == TOK_LEFT) {
781                 focused->rect.x -= px;
782                 focused->rect.width += px;
783             } else {
784                 focused->rect.width += px;
785             }
786         } else {
787             LOG("tiling resize\n");
788             /* get the default percentage */
789             int children = con_num_children(focused->parent);
790             Con *other;
791             LOG("ins. %d children\n", children);
792             double percentage = 1.0 / children;
793             LOG("default percentage = %f\n", percentage);
794
795             if (direction == TOK_UP || direction == TOK_LEFT) {
796                 other = TAILQ_PREV(focused, nodes_head, nodes);
797             } else {
798                 other = TAILQ_NEXT(focused, nodes);
799             }
800             if (other == TAILQ_END(workspaces)) {
801                 LOG("No other container in this direction found, cannot resize.\n");
802                 return 0;
803             }
804             LOG("other->percent = %f\n", other->percent);
805             LOG("focused->percent before = %f\n", focused->percent);
806             if (focused->percent == 0.0)
807                 focused->percent = percentage;
808             if (other->percent == 0.0)
809                 other->percent = percentage;
810             focused->percent += ((double)ppt / 100.0);
811             other->percent -= ((double)ppt / 100.0);
812             LOG("focused->percent after = %f\n", focused->percent);
813             LOG("other->percent after = %f\n", other->percent);
814         }
815
816         tree_render();
817     }
818     ;
819
820 resize_px:
821     /* empty */
822     {
823         $$ = 10;
824     }
825     | NUMBER TOK_PX
826     {
827         $$ = $1;
828     }
829     ;
830
831 resize_tiling:
832     /* empty */
833     {
834         $$ = 10;
835     }
836     | TOK_OR NUMBER TOK_PPT
837     {
838         $$ = $2;
839     }
840     ;
841
842 resize_way:
843     TOK_GROW        { $$ = TOK_GROW; }
844     | TOK_SHRINK    { $$ = TOK_SHRINK; }
845     ;
846
847 direction:
848     TOK_UP          { $$ = TOK_UP; }
849     | TOK_DOWN      { $$ = TOK_DOWN; }
850     | TOK_LEFT      { $$ = TOK_LEFT; }
851     | TOK_RIGHT     { $$ = TOK_RIGHT; }
852     ;
853
854 mode:
855     TOK_MODE STR
856     {
857         switch_mode($2);
858     }
859     ;