extern int yylex(void);
extern FILE *yyin;
+static struct bindings_head *current_bindings;
+
int yydebug = 1;
void yyerror(const char *str) {
int number;
char *string;
struct Colortriple *color;
- struct Assignment *assignment;
+ struct Assignment *assignment;
+ struct Binding *binding;
}
%token <number>NUMBER
%token TOKEXEC
%token TOKCOLOR
%token TOKARROW
+%token TOKMODE
%%
;
line:
- bind
- | bindsym
+ bindline
+ | mode
| floating_modifier
| workspace
| assign
STR
;
+bindline:
+ binding
+ {
+ TAILQ_INSERT_TAIL(&bindings, $<binding>1, bindings);
+ }
+ ;
+
+binding:
+ TOKBIND WHITESPACE bind { $<binding>$ = $<binding>3; }
+ | TOKBINDSYM WHITESPACE bindsym { $<binding>$ = $<binding>3; }
+ ;
+
bind:
- TOKBIND WHITESPACE binding_modifiers NUMBER WHITESPACE command
+ binding_modifiers NUMBER WHITESPACE command
{
- printf("\tFound binding mod%d with key %d and command %s\n", $<number>3, $4, $<string>6);
+ printf("\tFound binding mod%d with key %d and command %s\n", $<number>1, $2, $<string>4);
Binding *new = scalloc(sizeof(Binding));
- new->keycode = $<number>4;
- new->mods = $<number>3;
- new->command = sstrdup($<string>6);
+ new->keycode = $<number>2;
+ new->mods = $<number>1;
+ new->command = sstrdup($<string>4);
- TAILQ_INSERT_TAIL(&bindings, new, bindings);
+ $<binding>$ = new;
}
;
bindsym:
- TOKBINDSYM WHITESPACE binding_modifiers WORD WHITESPACE command
+ binding_modifiers WORD WHITESPACE command
{
- printf("\tFound symbolic mod%d with key %s and command %s\n", $<number>3, $4, $<string>6);
+ printf("\tFound symbolic mod%d with key %s and command %s\n", $<number>1, $2, $<string>4);
Binding *new = scalloc(sizeof(Binding));
- new->symbol = sstrdup($4);
- new->mods = $<number>3;
- new->command = sstrdup($<string>6);
+ new->symbol = sstrdup($2);
+ new->mods = $<number>1;
+ new->command = sstrdup($<string>4);
+
+ $<binding>$ = new;
+ }
+ ;
+
+mode:
+ TOKMODE WHITESPACE QUOTEDSTRING WHITESPACE '{' modelines '}'
+ {
+ printf("\t now in mode %s\n", $<string>3);
+ printf("\t current bindings = %p\n", current_bindings);
+ }
+ ;
+
+modelines:
+ /* empty */
+ | modelines WHITESPACE modeline
+ | modelines modeline
+ ;
+
+modeline:
+ comment
+ | binding
+ {
+ if (current_bindings == NULL) {
+ current_bindings = scalloc(sizeof(struct bindings_head));
+ TAILQ_INIT(current_bindings);
+ }
- TAILQ_INSERT_TAIL(&bindings, new, bindings);
+ TAILQ_INSERT_TAIL(current_bindings, $<binding>1, bindings);
}
;