#include "cfgparse.tab.h"
#include <xcb/xcb.h>
-enum {
- BIND_NONE = 0,
- BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
- BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
- BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
- BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
- BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
- BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
- BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
- BIND_MODE_SWITCH = (1 << 8)
-};
+#include "data.h"
%}
-%Start BIND_COND BIND_AWS_COND BIND_A2WS_COND ASSIGN_COND
+%Start BIND_COND BIND_AWS_COND BIND_A2WS_COND ASSIGN_COND COLOR_COND
%%
+<BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
+#[^\n]* return TOKCOMMENT;
[0-9]+ yylval.number = atoi(yytext); return NUMBER;
-[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; }
bindsym { BEGIN(BIND_COND); return TOKBINDSYM; }
floating_modifier return TOKFLOATING_MODIFIER;
workspace return TOKWORKSPACE;
screen return TOKSCREEN;
+terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
+font { BEGIN(BIND_AWS_COND); return TOKFONT; }
assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
set { BEGIN(BIND_COND); return TOKSET; }
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
-client.focused { /* TODO: lval pointer */ return TOKCOLOR; }
+client.focused { BEGIN(COLOR_COND); /* TODO: lval pointer */ return TOKCOLOR; }
Mod1 yylval.number = BIND_MOD1; return MODIFIER;
Mod2 yylval.number = BIND_MOD2; return MODIFIER;
Mod3 yylval.number = BIND_MOD3; return MODIFIER;
<BIND_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
<BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
[ \t]+ return WHITESPACE;
-<BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STRING; }
-<ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STRING_NG; }
+<ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
[a-zA-Z]+ yylval.string = strdup(yytext); return WORD;
[a-zA-Z0-9_-]+ yylval.string = strdup(yytext); return VARNAME;
\"[^\"]+\" {
#include <string.h>
#include <xcb/xcb.h>
-enum {
- BIND_NONE = 0,
- BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
- BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
- BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
- BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
- BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
- BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
- BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
- BIND_MODE_SWITCH = (1 << 8)
-};
+#include "data.h"
+extern int yylex(void);
+extern FILE *yyin;
int yydebug = 1;
-void yyerror(const char *str)
-{
+void yyerror(const char *str) {
fprintf(stderr,"error: %s\n",str);
}
-int yywrap()
-{
+int yywrap() {
return 1;
}
+void parse_file(const char *f) {
+ printf("opening %s\n", f);
+ if ((yyin = fopen(f, "r")) == NULL) {
+ perror("fopen");
+ exit(1);
+ }
+ if (yyparse() != 0) {
+ fprintf(stderr, "Could not parse configfile\n");
+ exit(1);
+ }
+ fclose(yyin);
+}
+
#if 0
main()
{
%token <number>NUMBER
%token <string>WORD
-%token <string>STRING
-%token <string>STRING_NG
+%token <string>STR
+%token <string>STR_NG
%token <string>VARNAME
%token <string>HEX
%token TOKBIND
+%token TOKTERMINAL
+%token TOKCOMMENT
+%token TOKFONT
%token TOKBINDSYM
%token MODIFIER
%token TOKCONTROL
| ipcsocket
| exec
| color
+ | terminal
+ | font
+ | comment
;
+comment:
+ TOKCOMMENT
+ ;
+
command:
- STRING
+ STR
;
bind:
window_class:
QUOTEDSTRING
- | STRING_NG
+ | STR_NG
;
optional_arrow:
;
set:
- TOKSET WHITESPACE variable WHITESPACE STRING
+ TOKSET WHITESPACE variable WHITESPACE STR
{
printf("set %s to %s\n", $<string>3, $<string>5);
}
;
ipcsocket:
- TOKIPCSOCKET WHITESPACE STRING
+ TOKIPCSOCKET WHITESPACE STR
{
printf("ipc %s\n", $<string>3);
}
;
exec:
- TOKEXEC WHITESPACE STRING
+ TOKEXEC WHITESPACE STR
{
printf("exec %s\n", $<string>3);
}
;
+terminal:
+ TOKTERMINAL WHITESPACE STR
+ {
+ printf("terminal %s\n", $<string>3);
+ }
+ ;
+
+font:
+ TOKFONT WHITESPACE STR
+ {
+ printf("font %s\n", $<string>3);
+ }
+ ;
+
+
color:
TOKCOLOR WHITESPACE '#' HEX
{
start_argv = argv;
- while ((opt = getopt_long(argc, argv, "c:vah", long_options, &option_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:vahp", long_options, &option_index)) != -1) {
switch (opt) {
case 'a':
LOG("Autostart disabled using -a\n");
case 'v':
printf("i3 version " I3_VERSION " © 2009 Michael Stapelberg and contributors\n");
exit(EXIT_SUCCESS);
+ case 'p':
+ {
+ printf("parsing\n");
+ parse_file(override_configpath);
+ exit(0);
+ }
default:
fprintf(stderr, "Usage: %s [-c configfile] [-a] [-v]\n", argv[0]);
fprintf(stderr, "\n");