]> git.sur5r.net Git - i3/i3/blob - src/cfgparse.l
Bugfix: Don’t leak IPC socket to launched processes
[i3/i3] / src / cfgparse.l
1 %option nounput
2 %option noinput
3
4 %{
5 /*
6  * vim:ts=8:expandtab
7  *
8  */
9 #include <stdio.h>
10 #include <string.h>
11 #include "cfgparse.tab.h"
12 #include <xcb/xcb.h>
13
14 #include "data.h"
15 #include "config.h"
16 %}
17
18 %Start BIND_COND
19 %Start BINDSYM_COND
20 %Start BIND_AWS_COND
21 %Start BINDSYM_AWS_COND
22 %Start BIND_A2WS_COND
23 %Start ASSIGN_COND
24 %Start COLOR_COND
25 %Start SCREEN_COND
26 %Start SCREEN_AWS_COND
27
28 %%
29 <BIND_A2WS_COND>[^\n]+          { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
30 ^[ \t]*#[^\n]*                  { return TOKCOMMENT; }
31 <COLOR_COND>[0-9a-fA-F]+        { yylval.string = strdup(yytext); return HEX; }
32 [0-9]+                          { yylval.number = atoi(yytext); return NUMBER; }
33 mode                            { return TOKMODE; }
34 bind                            { BEGIN(BIND_COND); return TOKBIND; }
35 bindsym                         { BEGIN(BINDSYM_COND); return TOKBINDSYM; }
36 floating_modifier               { BEGIN(INITIAL); return TOKFLOATING_MODIFIER; }
37 workspace                       { BEGIN(INITIAL); return TOKWORKSPACE; }
38 screen                          { BEGIN(SCREEN_COND); return TOKSCREEN; }
39 terminal                        { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
40 font                            { BEGIN(BIND_AWS_COND); return TOKFONT; }
41 assign                          { BEGIN(ASSIGN_COND); return TOKASSIGN; }
42 set[^\n]*                       { return TOKCOMMENT; }
43 ipc-socket                      { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
44 ipc_socket                      { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
45 new_container                   { return TOKNEWCONTAINER; }
46 new_window                      { return TOKNEWWINDOW; }
47 default                         { yylval.number = MODE_DEFAULT; return TOKCONTAINERMODE; }
48 stacking                        { yylval.number = MODE_STACK; return TOKCONTAINERMODE; }
49 tabbed                          { yylval.number = MODE_TABBED; return TOKCONTAINERMODE; }
50 stack-limit                     { return TOKSTACKLIMIT; }
51 cols                            { yylval.number = STACK_LIMIT_COLS; return TOKSTACKLIMIT; }
52 rows                            { yylval.number = STACK_LIMIT_ROWS; return TOKSTACKLIMIT; }
53 exec                            { BEGIN(BIND_AWS_COND); return TOKEXEC; }
54 client.focused                  { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
55 client.focused_inactive         { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
56 client.unfocused                { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
57 client.urgent                   { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
58 bar.focused                     { BEGIN(COLOR_COND); yylval.color = &config.bar.focused; return TOKCOLOR; }
59 bar.unfocused                   { BEGIN(COLOR_COND); yylval.color = &config.bar.unfocused; return TOKCOLOR; }
60 bar.urgent                      { BEGIN(COLOR_COND); yylval.color = &config.bar.urgent; return TOKCOLOR; }
61 Mod1                            { yylval.number = BIND_MOD1; return MODIFIER; }
62 Mod2                            { yylval.number = BIND_MOD2; return MODIFIER; }
63 Mod3                            { yylval.number = BIND_MOD3; return MODIFIER; }
64 Mod4                            { yylval.number = BIND_MOD4; return MODIFIER; }
65 Mod5                            { yylval.number = BIND_MOD5; return MODIFIER; }
66 Mode_switch                     { yylval.number = BIND_MODE_SWITCH; return MODIFIER; }
67 control                         { return TOKCONTROL; }
68 ctrl                            { return TOKCONTROL; }
69 shift                           { return TOKSHIFT; }
70 →                               { return TOKARROW; }
71 \n                              /* ignore end of line */;
72 <SCREEN_AWS_COND>x              { return (int)yytext[0]; }
73 <BIND_COND>[ \t]+               { BEGIN(BIND_AWS_COND); return WHITESPACE; }
74 <BINDSYM_COND>[ \t]+            { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; }
75 <BIND_AWS_COND>[ \t]+           { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
76 <BINDSYM_AWS_COND>[ \t]+        { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
77 <SCREEN_COND>[ \t]+             { BEGIN(SCREEN_AWS_COND); return WHITESPACE; }
78 <SCREEN_AWS_COND>[ \t]+         { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
79 [ \t]+                          { return WHITESPACE; }
80 \"[^\"]+\"                      {
81                                   /* if ASSIGN_COND then */
82                                   BEGIN(INITIAL);
83                                   /* yylval will be the string, but without quotes */
84                                   char *copy = strdup(yytext+1);
85                                   copy[strlen(copy)-1] = '\0';
86                                   yylval.string = copy;
87                                   return QUOTEDSTRING;
88                                 }
89 <ASSIGN_COND>[^ \t]+            { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
90 <BINDSYM_AWS_COND>[a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return WORD; }
91 [a-zA-Z]+                       { yylval.string = strdup(yytext); return WORD; }
92 .                               { return (int)yytext[0]; }
93 %%