]> git.sur5r.net Git - i3/i3/commitdiff
debugging: implement a NOP command which just spits out its argument
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 20 Nov 2010 17:40:25 +0000 (18:40 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 20 Nov 2010 17:40:25 +0000 (18:40 +0100)
You can use this in testcases to mark specific sections:
  $i3->command('nop before trying to crash')->recv;
leads to the following output in the i3 logfile:
  -------------------------------------------------
    NOP: before trying to crash
  -------------------------------------------------

src/cmdparse.l
src/cmdparse.y

index 9a236efc3cc7a08ddb1871ad3cccc6cc3f5cc783..d832057803a005ea0e233c564f7fffc8a7d814e7 100644 (file)
@@ -120,6 +120,7 @@ grow                            { return TOK_GROW; }
 px                              { return TOK_PX; }
 or                              { return TOK_OR; }
 ppt                             { return TOK_PPT; }
+nop                             { BEGIN(WANT_WS_STRING); return TOK_NOP; }
 restore                         { BEGIN(WANT_WS_STRING); return TOK_RESTORE; }
 mark                            { BEGIN(WANT_WS_STRING); return TOK_MARK; }
 
index 7f9dfd46c2d411d6ccdb0c269e1066507d0d851b..c2f0222eff1d37f596a24bae6f12b10302597750 100644 (file)
@@ -144,6 +144,7 @@ char *parse_cmd(const char *new) {
 %token TOK_PX "px"
 %token TOK_OR "or"
 %token TOK_PPT "ppt"
+%token TOK_NOP "nop"
 
 %token TOK_CLASS "class"
 %token TOK_ID "id"
@@ -306,6 +307,7 @@ operation:
     | level
     | mark
     | resize
+    | nop
     ;
 
 exec:
@@ -609,6 +611,16 @@ mark:
     }
     ;
 
+nop:
+    TOK_NOP WHITESPACE STR
+    {
+        printf("-------------------------------------------------\n");
+        printf("  NOP: %s\n", $<string>3);
+        printf("-------------------------------------------------\n");
+        free($<string>3);
+    }
+    ;
+
 resize:
     TOK_RESIZE WHITESPACE resize_way WHITESPACE direction resize_px resize_tiling
     {