]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Fix parsing symbols which contain numbers, like F1 or 1 for bindsym (Thanks...
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 29 Sep 2009 09:32:57 +0000 (11:32 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 29 Sep 2009 09:32:57 +0000 (11:32 +0200)
src/cfgparse.l
src/cfgparse.y

index 45ea6333b32b6c0fd4261b1426b5ddf094581b09..c54d346c3d6737e78390856d74ff55cdd61a484b 100644 (file)
@@ -13,7 +13,9 @@
 %}
 
 %Start BIND_COND
+%Start BINDSYM_COND
 %Start BIND_AWS_COND
+%Start BINDSYM_AWS_COND
 %Start BIND_A2WS_COND
 %Start ASSIGN_COND
 %Start COLOR_COND
@@ -27,7 +29,7 @@
 [0-9]+                          { yylval.number = atoi(yytext); return NUMBER; }
 mode                            { return TOKMODE; }
 bind                            { BEGIN(BIND_COND); return TOKBIND; }
-bindsym                         { BEGIN(BIND_COND); return TOKBINDSYM; }
+bindsym                         { BEGIN(BINDSYM_COND); return TOKBINDSYM; }
 floating_modifier               { return TOKFLOATING_MODIFIER; }
 workspace                       { BEGIN(INITIAL); return TOKWORKSPACE; }
 screen                          { BEGIN(SCREEN_COND); return TOKSCREEN; }
@@ -64,7 +66,9 @@ shift                           { return TOKSHIFT; }
 \n                              /* ignore end of line */;
 <SCREEN_AWS_COND>x              { return (int)yytext[0]; }
 <BIND_COND>[ \t]+               { BEGIN(BIND_AWS_COND); return WHITESPACE; }
+<BINDSYM_COND>[ \t]+            { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; }
 <BIND_AWS_COND>[ \t]+           { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
+<BINDSYM_AWS_COND>[ \t]+        { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
 <SCREEN_COND>[ \t]+             { BEGIN(SCREEN_AWS_COND); return WHITESPACE; }
 <SCREEN_AWS_COND>[ \t]+         { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
 [ \t]+                          { return WHITESPACE; }
@@ -78,6 +82,7 @@ shift                           { return TOKSHIFT; }
                                   return QUOTEDSTRING;
                                 }
 <ASSIGN_COND>[^ \t]+            { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
+<BINDSYM_AWS_COND>[a-zA-Z0-9]+  { yylval.string = strdup(yytext); return WORD; }
 [a-zA-Z]+                       { yylval.string = strdup(yytext); return WORD; }
 .                               { return (int)yytext[0]; }
 %%
index d706b4001b6157f2822fa3bd62ebabad87709065..26e00af9ebc26291f24f7f248077d52f87ba6bb8 100644 (file)
@@ -250,12 +250,12 @@ bind:
         ;
 
 bindsym:
-        binding_modifiers WORD WHITESPACE command
+        binding_modifiers word_or_number WHITESPACE command
         {
-                printf("\tFound symbolic mod%d with key %s and command %s\n", $<number>1, $2, $<string>4);
+                printf("\tFound symbolic mod%d with key %s and command %s\n", $<number>1, $<string>2, $<string>4);
                 Binding *new = scalloc(sizeof(Binding));
 
-                new->symbol = sstrdup($2);
+                new->symbol = sstrdup($<string>2);
                 new->mods = $<number>1;
                 new->command = sstrdup($<string>4);
 
@@ -263,6 +263,14 @@ bindsym:
         }
         ;
 
+word_or_number:
+        WORD
+        | NUMBER
+        {
+                asprintf(&$<string>$, "%d", $1);
+        }
+        ;
+
 mode:
         TOKMODE WHITESPACE QUOTEDSTRING WHITESPACE '{' modelines '}'
         {