Fix some parsing problems, retab!
This commit is contained in:
parent
268bf71222
commit
2986636e03
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@ src/cfgparse.yy.o: src/cfgparse.l
|
||||||
|
|
||||||
src/cfgparse.y.o: src/cfgparse.y
|
src/cfgparse.y.o: src/cfgparse.y
|
||||||
echo "YACC $<"
|
echo "YACC $<"
|
||||||
yacc -b $(basename $< .y) -d $<
|
yacc --debug --verbose -b $(basename $< .y) -d $<
|
||||||
$(CC) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
|
$(CC) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
|
|
|
@ -4,49 +4,71 @@
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%Start BIND_COND BIND_AWS_COND BIND_A2WS_COND ASSIGN_COND COLOR_COND
|
%Start BIND_COND
|
||||||
|
%Start BIND_AWS_COND
|
||||||
|
%Start BIND_A2WS_COND
|
||||||
|
%Start ASSIGN_COND
|
||||||
|
%Start COLOR_COND
|
||||||
|
%Start SET_COND
|
||||||
|
%Start SET_AWS_COND
|
||||||
|
%Start SCREEN_COND
|
||||||
|
%Start SCREEN_AWS_COND
|
||||||
|
|
||||||
%%
|
%%
|
||||||
<BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
|
<BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
|
||||||
#[^\n]* return TOKCOMMENT;
|
^#[^\n]* { return TOKCOMMENT; }
|
||||||
[0-9]+ yylval.number = atoi(yytext); return NUMBER;
|
[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
|
||||||
<COLOR_COND>[0-9a-fA-F]+ { yylval.string = strdup(yytext); return HEX; }
|
<COLOR_COND>[0-9a-fA-F]+ { yylval.string = strdup(yytext); return HEX; }
|
||||||
bind { BEGIN(BIND_COND); return TOKBIND; }
|
bind { BEGIN(BIND_COND); return TOKBIND; }
|
||||||
bindsym { BEGIN(BIND_COND); return TOKBINDSYM; }
|
bindsym { BEGIN(BIND_COND); return TOKBINDSYM; }
|
||||||
floating_modifier return TOKFLOATING_MODIFIER;
|
floating_modifier { return TOKFLOATING_MODIFIER; }
|
||||||
workspace return TOKWORKSPACE;
|
workspace { BEGIN(INITIAL); return TOKWORKSPACE; }
|
||||||
screen return TOKSCREEN;
|
screen { BEGIN(SCREEN_COND); return TOKSCREEN; }
|
||||||
terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
|
terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
|
||||||
font { BEGIN(BIND_AWS_COND); return TOKFONT; }
|
font { BEGIN(BIND_AWS_COND); return TOKFONT; }
|
||||||
assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
|
assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
|
||||||
set { BEGIN(BIND_COND); return TOKSET; }
|
set { BEGIN(SET_COND); return TOKSET; }
|
||||||
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
||||||
exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
|
exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
|
||||||
client.focused { BEGIN(COLOR_COND); /* TODO: lval pointer */ return TOKCOLOR; }
|
client.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
|
||||||
Mod1 yylval.number = BIND_MOD1; return MODIFIER;
|
client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
|
||||||
Mod2 yylval.number = BIND_MOD2; return MODIFIER;
|
client.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
|
||||||
Mod3 yylval.number = BIND_MOD3; return MODIFIER;
|
client.urgent { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
|
||||||
Mod4 yylval.number = BIND_MOD4; return MODIFIER;
|
bar.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
|
||||||
Mod5 yylval.number = BIND_MOD5; return MODIFIER;
|
bar.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
|
||||||
control return TOKCONTROL;
|
bar.urgent { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
|
||||||
shift return TOKSHIFT;
|
Mod1 { yylval.number = BIND_MOD1; return MODIFIER; }
|
||||||
→ return TOKARROW;
|
Mod2 { yylval.number = BIND_MOD2; return MODIFIER; }
|
||||||
|
Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
|
||||||
|
Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
|
||||||
|
Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
|
||||||
|
control { return TOKCONTROL; }
|
||||||
|
shift { return TOKSHIFT; }
|
||||||
|
→ { return TOKARROW; }
|
||||||
\n /* ignore end of line */;
|
\n /* ignore end of line */;
|
||||||
|
<SCREEN_AWS_COND>x { return (int)yytext[0]; }
|
||||||
<BIND_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
|
<BIND_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
|
||||||
|
<SET_COND>[ \t]+ { BEGIN(SET_AWS_COND); return WHITESPACE; }
|
||||||
<BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
<BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
||||||
[ \t]+ return WHITESPACE;
|
<SET_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
||||||
<ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
|
<SCREEN_COND>[ \t]+ { BEGIN(SCREEN_AWS_COND); return WHITESPACE; }
|
||||||
[a-zA-Z]+ yylval.string = strdup(yytext); return WORD;
|
<SCREEN_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
||||||
[a-zA-Z0-9_-]+ yylval.string = strdup(yytext); return VARNAME;
|
[ \t]+ { return WHITESPACE; }
|
||||||
\"[^\"]+\" {
|
\"[^\"]+\" {
|
||||||
|
/* if ASSIGN_COND then */
|
||||||
|
BEGIN(INITIAL);
|
||||||
/* yylval will be the string, but without quotes */
|
/* yylval will be the string, but without quotes */
|
||||||
char *copy = strdup(yytext+1);
|
char *copy = strdup(yytext+1);
|
||||||
copy[strlen(copy)-1] = '\0';
|
copy[strlen(copy)-1] = '\0';
|
||||||
yylval.string = copy;
|
yylval.string = copy;
|
||||||
return QUOTEDSTRING;
|
return QUOTEDSTRING;
|
||||||
}
|
}
|
||||||
. return (int) yytext[0];
|
<ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
|
||||||
|
[a-zA-Z]+ { yylval.string = strdup(yytext); return WORD; }
|
||||||
|
<SET_AWS_COND>[a-zA-Z0-9_-]+ { yylval.string = strdup(yytext); return VARNAME; }
|
||||||
|
. { return (int)yytext[0]; }
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
extern int yylex(void);
|
extern int yylex(void);
|
||||||
extern FILE *yyin;
|
extern FILE *yyin;
|
||||||
|
@ -44,6 +45,7 @@ main()
|
||||||
%union {
|
%union {
|
||||||
int number;
|
int number;
|
||||||
char *string;
|
char *string;
|
||||||
|
struct Colortriple *color;
|
||||||
}
|
}
|
||||||
|
|
||||||
%token <number>NUMBER
|
%token <number>NUMBER
|
||||||
|
@ -103,16 +105,16 @@ command:
|
||||||
;
|
;
|
||||||
|
|
||||||
bind:
|
bind:
|
||||||
TOKBIND WHITESPACE binding_modifiers '+' NUMBER WHITESPACE command
|
TOKBIND WHITESPACE binding_modifiers NUMBER WHITESPACE command
|
||||||
{
|
{
|
||||||
printf("\tFound binding mod%d with key %d and command %s\n", $<number>3, $5, $<string>7);
|
printf("\tFound binding mod%d with key %d and command %s\n", $<number>3, $4, $<string>6);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
bindsym:
|
bindsym:
|
||||||
TOKBINDSYM WHITESPACE binding_modifiers '+' WORD WHITESPACE command
|
TOKBINDSYM WHITESPACE binding_modifiers WORD WHITESPACE command
|
||||||
{
|
{
|
||||||
printf("\tFound symbolic mod%d with key %s and command %s\n", $<number>3, $5, $<string>7);
|
printf("\tFound symbolic mod%d with key %s and command %s\n", $<number>3, $4, $<string>6);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -126,18 +128,25 @@ floating_modifier:
|
||||||
workspace:
|
workspace:
|
||||||
TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen
|
TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen
|
||||||
{
|
{
|
||||||
printf("\t workspace %d to screen %d\n", $<number>3, $<number>7);
|
printf("\t workspace %d to screen %s\n", $<number>3, $<string>7);
|
||||||
}
|
}
|
||||||
| TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen WHITESPACE QUOTEDSTRING
|
| TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen WHITESPACE workspace_name
|
||||||
{
|
{
|
||||||
printf("\t quoted: %s\n", $<string>9);
|
printf("\t quoted: %s\n", $<string>9);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
screen:
|
workspace_name:
|
||||||
NUMBER
|
QUOTEDSTRING
|
||||||
|
| STR
|
||||||
;
|
;
|
||||||
|
|
||||||
|
screen:
|
||||||
|
NUMBER { asprintf(&$<string>$, "%d", $<number>1); }
|
||||||
|
| NUMBER 'x' { asprintf(&$<string>$, "%d", $<number>1); }
|
||||||
|
| NUMBER 'x' NUMBER { asprintf(&$<string>$, "%dx%d", $<number>1, $<number>3); }
|
||||||
|
| 'x' NUMBER { asprintf(&$<string>$, "x%d", $<number>2); }
|
||||||
|
;
|
||||||
|
|
||||||
assign:
|
assign:
|
||||||
TOKASSIGN WHITESPACE window_class WHITESPACE optional_arrow NUMBER
|
TOKASSIGN WHITESPACE window_class WHITESPACE optional_arrow NUMBER
|
||||||
|
@ -198,20 +207,18 @@ font:
|
||||||
|
|
||||||
|
|
||||||
color:
|
color:
|
||||||
TOKCOLOR WHITESPACE '#' HEX
|
TOKCOLOR WHITESPACE '#' HEX WHITESPACE '#' HEX WHITESPACE '#' HEX
|
||||||
{
|
{
|
||||||
printf("color %s\n", $<string>4);
|
printf("color %p, %s and %s and %s\n", $<color>1, $<string>4, $<string>7, $<string>10);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
binding_modifiers:
|
binding_modifiers:
|
||||||
binding_modifier
|
/* NULL */ { $<number>$ = 0; }
|
||||||
|
|
| binding_modifier
|
||||||
binding_modifiers '+' binding_modifier
|
| binding_modifiers '+' binding_modifier { $<number>$ = $<number>1 | $<number>3; }
|
||||||
{
|
| binding_modifiers '+' { $<number>$ = $<number>1; }
|
||||||
$<number>$ = $<number>1 | $<number>3;
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
binding_modifier:
|
binding_modifier:
|
||||||
|
|
Loading…
Reference in New Issue