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 <OUTPUT_AWS_COND>[a-zA-Z0-9_-]+ { yylval.string = strdup(yytext); return OUTPUT; }
71 ^[ \t]*#[^\n]* { return TOKCOMMENT; }
72 <COLOR_COND>[0-9a-fA-F]+ { yylval.string = strdup(yytext); return HEX; }
73 [0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
74 mode { return TOKMODE; }
75 bind { BEGIN(BIND_COND); return TOKBIND; }
76 bindsym { BEGIN(BINDSYM_COND); return TOKBINDSYM; }
77 floating_modifier { BEGIN(INITIAL); return TOKFLOATING_MODIFIER; }
78 workspace { BEGIN(INITIAL); return TOKWORKSPACE; }
79 output { BEGIN(OUTPUT_COND); return TOKOUTPUT; }
81 /* for compatibility until v3.φ */
82 ELOG("Assignments to screens are DEPRECATED and will not work. " \
83 "Please replace them with assignments to outputs.\n");
87 terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
88 font { BEGIN(BIND_AWS_COND); return TOKFONT; }
89 assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
90 set[^\n]* { return TOKCOMMENT; }
91 ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
92 ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
93 new_container { return TOKNEWCONTAINER; }
94 new_window { return TOKNEWWINDOW; }
95 focus_follows_mouse { return TOKFOCUSFOLLOWSMOUSE; }
96 workspace_bar { return TOKWORKSPACEBAR; }
97 default { /* yylval.number = MODE_DEFAULT; */return TOKCONTAINERMODE; }
98 stacking { /* yylval.number = MODE_STACK; */return TOKCONTAINERMODE; }
99 tabbed { /* yylval.number = MODE_TABBED; */return TOKCONTAINERMODE; }
100 stack-limit { return TOKSTACKLIMIT; }
101 cols { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; }
102 rows { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; }
103 exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
104 client.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
105 client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
106 client.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
107 client.urgent { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
108 bar.focused { BEGIN(COLOR_COND); yylval.color = &config.bar.focused; return TOKCOLOR; }
109 bar.unfocused { BEGIN(COLOR_COND); yylval.color = &config.bar.unfocused; return TOKCOLOR; }
110 bar.urgent { BEGIN(COLOR_COND); yylval.color = &config.bar.urgent; return TOKCOLOR; }
111 Mod1 { yylval.number = BIND_MOD1; return MODIFIER; }
112 Mod2 { yylval.number = BIND_MOD2; return MODIFIER; }
113 Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
114 Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
115 Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
116 Mode_switch { yylval.number = BIND_MODE_SWITCH; return MODIFIER; }
117 control { return TOKCONTROL; }
118 ctrl { return TOKCONTROL; }
119 shift { return TOKSHIFT; }
120 → { return TOKARROW; }
122 FREE(context->line_copy);
123 context->line_number++;
125 yy_push_state(BUFFER_LINE);
127 <BIND_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
128 <BINDSYM_COND>[ \t]+ { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; }
129 <BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
130 <BINDSYM_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
131 <OUTPUT_COND>[ \t]+ { BEGIN(OUTPUT_AWS_COND); return WHITESPACE; }
132 <OUTPUT_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
133 [ \t]+ { return WHITESPACE; }
135 /* if ASSIGN_COND then */
137 /* yylval will be the string, but without quotes */
138 char *copy = strdup(yytext+1);
139 copy[strlen(copy)-1] = '\0';
140 yylval.string = copy;
143 <ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
144 <BINDSYM_AWS_COND>[a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return WORD; }
145 [a-zA-Z]+ { yylval.string = strdup(yytext); return WORD; }
146 . { return (int)yytext[0]; }
149 while (yy_start_stack_ptr > 0)