13 #include "cfgparse.tab.h"
23 #define YY_DECL int yylex (struct context *context)
25 #define YY_USER_ACTION { \
26 context->first_column = yycolumn; \
27 context->last_column = yycolumn+yyleng-1; \
49 /* This is called when a new line is lexed. We only want the
50 * first line to match to go into state BUFFER_LINE */
51 if (context->line_number == 0) {
52 context->line_number = 1;
54 yy_push_state(BUFFER_LINE);
58 <BUFFER_LINE>^[^\r\n]*/{EOL}? {
60 context->line_copy = strdup(yytext);
69 <BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
70 ^[ \t]*#[^\n]* { return TOKCOMMENT; }
71 <COLOR_COND>[0-9a-fA-F]+ { yylval.string = strdup(yytext); return HEX; }
72 [0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
73 mode { return TOKMODE; }
74 bind { BEGIN(BIND_COND); return TOKBIND; }
75 bindsym { BEGIN(BINDSYM_COND); return TOKBINDSYM; }
76 floating_modifier { BEGIN(INITIAL); return TOKFLOATING_MODIFIER; }
77 workspace { BEGIN(INITIAL); return TOKWORKSPACE; }
78 screen { BEGIN(SCREEN_COND); return TOKSCREEN; }
79 terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
80 font { BEGIN(BIND_AWS_COND); return TOKFONT; }
81 assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
82 set[^\n]* { return TOKCOMMENT; }
83 ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
84 ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
85 new_container { return TOKNEWCONTAINER; }
86 new_window { return TOKNEWWINDOW; }
87 focus_follows_mouse { return TOKFOCUSFOLLOWSMOUSE; }
88 default { yylval.number = MODE_DEFAULT; return TOKCONTAINERMODE; }
89 stacking { yylval.number = MODE_STACK; return TOKCONTAINERMODE; }
90 tabbed { yylval.number = MODE_TABBED; return TOKCONTAINERMODE; }
91 stack-limit { return TOKSTACKLIMIT; }
92 cols { yylval.number = STACK_LIMIT_COLS; return TOKSTACKLIMIT; }
93 rows { yylval.number = STACK_LIMIT_ROWS; return TOKSTACKLIMIT; }
94 exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
95 client.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
96 client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
97 client.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
98 client.urgent { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
99 bar.focused { BEGIN(COLOR_COND); yylval.color = &config.bar.focused; return TOKCOLOR; }
100 bar.unfocused { BEGIN(COLOR_COND); yylval.color = &config.bar.unfocused; return TOKCOLOR; }
101 bar.urgent { BEGIN(COLOR_COND); yylval.color = &config.bar.urgent; return TOKCOLOR; }
102 Mod1 { yylval.number = BIND_MOD1; return MODIFIER; }
103 Mod2 { yylval.number = BIND_MOD2; return MODIFIER; }
104 Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
105 Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
106 Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
107 Mode_switch { yylval.number = BIND_MODE_SWITCH; return MODIFIER; }
108 control { return TOKCONTROL; }
109 ctrl { return TOKCONTROL; }
110 shift { return TOKSHIFT; }
111 → { return TOKARROW; }
113 FREE(context->line_copy);
114 context->line_number++;
115 yy_push_state(BUFFER_LINE);
117 <SCREEN_AWS_COND>x { return (int)yytext[0]; }
118 <BIND_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
119 <BINDSYM_COND>[ \t]+ { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; }
120 <BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
121 <BINDSYM_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
122 <SCREEN_COND>[ \t]+ { BEGIN(SCREEN_AWS_COND); return WHITESPACE; }
123 <SCREEN_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
124 [ \t]+ { return WHITESPACE; }
126 /* if ASSIGN_COND then */
128 /* yylval will be the string, but without quotes */
129 char *copy = strdup(yytext+1);
130 copy[strlen(copy)-1] = '\0';
131 yylval.string = copy;
134 <ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
135 <BINDSYM_AWS_COND>[a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return WORD; }
136 [a-zA-Z]+ { yylval.string = strdup(yytext); return WORD; }
137 . { return (int)yytext[0]; }
140 while (yy_start_stack_ptr > 0)