Finish configfile parsing with lexer, implement -l to use the lexer.
Every user is encouraged to use -l to switch to the new lexer and see if there are any problems.
This commit is contained in:
parent
207ad0a7df
commit
ca472559b9
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
typedef struct Config Config;
|
typedef struct Config Config;
|
||||||
extern Config config;
|
extern Config config;
|
||||||
|
extern bool config_use_lexer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of the struct Config. It makes sense to group colors for background,
|
* Part of the struct Config. It makes sense to group colors for background,
|
||||||
|
|
|
@ -43,6 +43,7 @@ Mod2 { yylval.number = BIND_MOD2; return MODIFIER; }
|
||||||
Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
|
Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
|
||||||
Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
|
Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
|
||||||
Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
|
Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
|
||||||
|
Mode_switch { yylval.number = BIND_MODE_SWITCH; return MODIFIER; }
|
||||||
control { return TOKCONTROL; }
|
control { return TOKCONTROL; }
|
||||||
shift { return TOKSHIFT; }
|
shift { return TOKSHIFT; }
|
||||||
→ { return TOKARROW; }
|
→ { return TOKARROW; }
|
||||||
|
|
|
@ -152,6 +152,7 @@ void parse_file(const char *f) {
|
||||||
int number;
|
int number;
|
||||||
char *string;
|
char *string;
|
||||||
struct Colortriple *color;
|
struct Colortriple *color;
|
||||||
|
struct Assignment *assignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
%token <number>NUMBER
|
%token <number>NUMBER
|
||||||
|
@ -272,13 +273,39 @@ screen:
|
||||||
;
|
;
|
||||||
|
|
||||||
assign:
|
assign:
|
||||||
TOKASSIGN WHITESPACE window_class WHITESPACE optional_arrow NUMBER
|
TOKASSIGN WHITESPACE window_class WHITESPACE optional_arrow assign_target
|
||||||
{
|
{
|
||||||
/* TODO */
|
|
||||||
printf("assignment of %s to %d\n", $<string>3, $<number>6);
|
printf("assignment of %s to %d\n", $<string>3, $<number>6);
|
||||||
|
|
||||||
|
struct Assignment *new = $<assignment>6;
|
||||||
|
new->windowclass_title = strdup($<string>3);
|
||||||
|
TAILQ_INSERT_TAIL(&assignments, new, assignments);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
assign_target:
|
||||||
|
NUMBER
|
||||||
|
{
|
||||||
|
struct Assignment *new = scalloc(sizeof(struct Assignment));
|
||||||
|
new->workspace = $<number>1;
|
||||||
|
new->floating = ASSIGN_FLOATING_NO;
|
||||||
|
$<assignment>$ = new;
|
||||||
|
}
|
||||||
|
| '~'
|
||||||
|
{
|
||||||
|
struct Assignment *new = scalloc(sizeof(struct Assignment));
|
||||||
|
new->floating = ASSIGN_FLOATING_ONLY;
|
||||||
|
$<assignment>$ = new;
|
||||||
|
}
|
||||||
|
| '~' NUMBER
|
||||||
|
{
|
||||||
|
struct Assignment *new = scalloc(sizeof(struct Assignment));
|
||||||
|
new->workspace = $<number>2;
|
||||||
|
new->floating = ASSIGN_FLOATING;
|
||||||
|
$<assignment>$ = new;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
window_class:
|
window_class:
|
||||||
QUOTEDSTRING
|
QUOTEDSTRING
|
||||||
| STR_NG
|
| STR_NG
|
||||||
|
|
28
src/config.c
28
src/config.c
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
|
bool config_use_lexer = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function resolves ~ in pathnames.
|
* This function resolves ~ in pathnames.
|
||||||
*
|
*
|
||||||
|
@ -226,6 +228,25 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
config.bar.urgent.background = get_colorpixel(conn, "#900000");
|
config.bar.urgent.background = get_colorpixel(conn, "#900000");
|
||||||
config.bar.urgent.text = get_colorpixel(conn, "#ffffff");
|
config.bar.urgent.text = get_colorpixel(conn, "#ffffff");
|
||||||
|
|
||||||
|
if (config_use_lexer) {
|
||||||
|
/* Yes, this will be cleaned up soon. */
|
||||||
|
if (override_configpath != NULL) {
|
||||||
|
parse_file(override_configpath);
|
||||||
|
} else {
|
||||||
|
FILE *handle;
|
||||||
|
char *globbed = glob_path("~/.i3/config");
|
||||||
|
if ((handle = fopen(globbed, "r")) == NULL) {
|
||||||
|
if ((handle = fopen("/etc/i3/config", "r")) == NULL) {
|
||||||
|
die("Neither \"%s\" nor /etc/i3/config could be opened\n", globbed);
|
||||||
|
} else {
|
||||||
|
parse_file("/etc/i3/config");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
parse_file(globbed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
if (override_configpath != NULL) {
|
if (override_configpath != NULL) {
|
||||||
if ((handle = fopen(override_configpath, "r")) == NULL)
|
if ((handle = fopen(override_configpath, "r")) == NULL)
|
||||||
|
@ -508,9 +529,6 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
grab_all_keys(conn);
|
grab_all_keys(conn);
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
|
|
||||||
REQUIRED_OPTION(terminal);
|
|
||||||
REQUIRED_OPTION(font);
|
|
||||||
|
|
||||||
while (!SLIST_EMPTY(&variables)) {
|
while (!SLIST_EMPTY(&variables)) {
|
||||||
struct Variable *v = SLIST_FIRST(&variables);
|
struct Variable *v = SLIST_FIRST(&variables);
|
||||||
SLIST_REMOVE_HEAD(&variables, variables);
|
SLIST_REMOVE_HEAD(&variables, variables);
|
||||||
|
@ -518,6 +536,10 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
free(v->value);
|
free(v->value);
|
||||||
free(v);
|
free(v);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
REQUIRED_OPTION(terminal);
|
||||||
|
REQUIRED_OPTION(font);
|
||||||
|
|
||||||
/* Set an empty name for every workspace which got no name */
|
/* Set an empty name for every workspace which got no name */
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
11
src/mainx.c
11
src/mainx.c
|
@ -165,7 +165,7 @@ int main(int argc, char *argv[], char *env[]) {
|
||||||
|
|
||||||
start_argv = argv;
|
start_argv = argv;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "c:vahp", long_options, &option_index)) != -1) {
|
while ((opt = getopt_long(argc, argv, "c:vahl", long_options, &option_index)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
LOG("Autostart disabled using -a\n");
|
LOG("Autostart disabled using -a\n");
|
||||||
|
@ -177,12 +177,9 @@ int main(int argc, char *argv[], char *env[]) {
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("i3 version " I3_VERSION " © 2009 Michael Stapelberg and contributors\n");
|
printf("i3 version " I3_VERSION " © 2009 Michael Stapelberg and contributors\n");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
case 'p':
|
case 'l':
|
||||||
{
|
config_use_lexer = true;
|
||||||
printf("parsing\n");
|
break;
|
||||||
parse_file(override_configpath);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Usage: %s [-c configfile] [-a] [-v]\n", argv[0]);
|
fprintf(stderr, "Usage: %s [-c configfile] [-a] [-v]\n", argv[0]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
Loading…
Reference in New Issue