%}
%Start BIND_COND
+%Start BINDSYM_COND
%Start BIND_AWS_COND
+%Start BINDSYM_AWS_COND
%Start BIND_A2WS_COND
%Start ASSIGN_COND
%Start COLOR_COND
[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; }
\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; }
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]; }
%%
;
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);
}
;
+word_or_number:
+ WORD
+ | NUMBER
+ {
+ asprintf(&$<string>$, "%d", $1);
+ }
+ ;
+
mode:
TOKMODE WHITESPACE QUOTEDSTRING WHITESPACE '{' modelines '}'
{