From ff0e9bb954cf953ec8324dff98fcfdc2c4b24193 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 29 Sep 2009 11:32:57 +0200 Subject: [PATCH] Bugfix: Fix parsing symbols which contain numbers, like F1 or 1 for bindsym (Thanks Rasi) --- src/cfgparse.l | 7 ++++++- src/cfgparse.y | 14 +++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cfgparse.l b/src/cfgparse.l index 45ea6333..c54d346c 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -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 */; x { return (int)yytext[0]; } [ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; } +[ \t]+ { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; } [ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; } +[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; } [ \t]+ { BEGIN(SCREEN_AWS_COND); return WHITESPACE; } [ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; } [ \t]+ { return WHITESPACE; } @@ -78,6 +82,7 @@ shift { return TOKSHIFT; } return QUOTEDSTRING; } [^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; } +[a-zA-Z0-9]+ { yylval.string = strdup(yytext); return WORD; } [a-zA-Z]+ { yylval.string = strdup(yytext); return WORD; } . { return (int)yytext[0]; } %% diff --git a/src/cfgparse.y b/src/cfgparse.y index d706b400..26e00af9 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -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", $1, $2, $4); + printf("\tFound symbolic mod%d with key %s and command %s\n", $1, $2, $4); Binding *new = scalloc(sizeof(Binding)); - new->symbol = sstrdup($2); + new->symbol = sstrdup($2); new->mods = $1; new->command = sstrdup($4); @@ -263,6 +263,14 @@ bindsym: } ; +word_or_number: + WORD + | NUMBER + { + asprintf(&$$, "%d", $1); + } + ; + mode: TOKMODE WHITESPACE QUOTEDSTRING WHITESPACE '{' modelines '}' {