21 #include "cfgparse.tab.h"
25 #define YY_DECL int yylex (struct context *context)
27 #define YY_USER_ACTION { \
28 context->first_column = yycolumn; \
29 context->last_column = yycolumn+yyleng-1; \
51 /* This is called when a new line is lexed. We only want the
52 * first line to match to go into state BUFFER_LINE */
53 if (context->line_number == 0) {
54 context->line_number = 1;
56 yy_push_state(BUFFER_LINE);
60 <BUFFER_LINE>^[^\r\n]*/{EOL}? {
62 context->line_copy = strdup(yytext);
71 <BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
72 <OUTPUT_AWS_COND>[a-zA-Z0-9_-]+ { yylval.string = strdup(yytext); return OUTPUT; }
73 ^[ \t]*#[^\n]* { return TOKCOMMENT; }
74 <COLOR_COND>[0-9a-fA-F]+ { yylval.string = strdup(yytext); return HEX; }
75 [0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
76 mode { return TOKMODE; }
77 bind { BEGIN(BINDCODE_COND); return TOKBINDCODE; }
78 bindcode { BEGIN(BINDCODE_COND); return TOKBINDCODE; }
79 bindsym { BEGIN(BINDSYM_COND); return TOKBINDSYM; }
80 floating_modifier { BEGIN(INITIAL); return TOKFLOATING_MODIFIER; }
81 workspace { BEGIN(INITIAL); return TOKWORKSPACE; }
82 output { BEGIN(OUTPUT_COND); return TOKOUTPUT; }
84 /* for compatibility until v3.φ */
85 ELOG("Assignments to screens are DEPRECATED and will not work. " \
86 "Please replace them with assignments to outputs.\n");
90 terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
91 font { BEGIN(BIND_AWS_COND); return TOKFONT; }
92 assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
93 set[^\n]* { return TOKCOMMENT; }
94 ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
95 ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
96 restart_state { BEGIN(BIND_AWS_COND); return TOKRESTARTSTATE; }
97 default_orientation { return TOK_ORIENTATION; }
98 horizontal { return TOK_HORIZ; }
99 vertical { return TOK_VERT; }
100 auto { return TOK_AUTO; }
101 workspace_layout { return TOK_WORKSPACE_LAYOUT; }
102 new_window { return TOKNEWWINDOW; }
103 normal { return TOK_NORMAL; }
104 none { return TOK_NONE; }
105 1pixel { return TOK_1PIXEL; }
106 focus_follows_mouse { return TOKFOCUSFOLLOWSMOUSE; }
107 workspace_bar { return TOKWORKSPACEBAR; }
108 popup_during_fullscreen { return TOK_POPUP_DURING_FULLSCREEN; }
109 ignore { return TOK_IGNORE; }
110 leave_fullscreen { return TOK_LEAVE_FULLSCREEN; }
111 default { /* yylval.number = MODE_DEFAULT; */return TOK_DEFAULT; }
112 stacking { /* yylval.number = MODE_STACK; */return TOK_STACKING; }
113 stacked { return TOK_STACKING; }
114 tabbed { /* yylval.number = MODE_TABBED; */return TOK_TABBED; }
115 stack-limit { return TOKSTACKLIMIT; }
116 cols { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; }
117 rows { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; }
118 exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
119 client.background { BEGIN(COLOR_COND); yylval.single_color = &config.client.background; return TOKSINGLECOLOR; }
120 client.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
121 client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
122 client.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
123 client.urgent { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
124 bar.focused { BEGIN(COLOR_COND); yylval.color = &config.bar.focused; return TOKCOLOR; }
125 bar.unfocused { BEGIN(COLOR_COND); yylval.color = &config.bar.unfocused; return TOKCOLOR; }
126 bar.urgent { BEGIN(COLOR_COND); yylval.color = &config.bar.urgent; return TOKCOLOR; }
127 Mod1 { yylval.number = BIND_MOD1; return MODIFIER; }
128 Mod2 { yylval.number = BIND_MOD2; return MODIFIER; }
129 Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
130 Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
131 Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
132 Mode_switch { yylval.number = BIND_MODE_SWITCH; return MODIFIER; }
133 control { return TOKCONTROL; }
134 ctrl { return TOKCONTROL; }
135 shift { return TOKSHIFT; }
136 → { return TOKARROW; }
138 FREE(context->line_copy);
139 context->line_number++;
141 yy_push_state(BUFFER_LINE);
143 <BINDCODE_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
144 <BINDSYM_COND>[ \t]+ { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; }
145 <BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
146 <BINDSYM_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
147 <OUTPUT_COND>[ \t]+ { BEGIN(OUTPUT_AWS_COND); return WHITESPACE; }
148 <OUTPUT_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
149 [ \t]+ { return WHITESPACE; }
151 /* if ASSIGN_COND then */
153 /* yylval will be the string, but without quotes */
154 char *copy = strdup(yytext+1);
155 copy[strlen(copy)-1] = '\0';
156 yylval.string = copy;
159 <ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
160 <BINDSYM_AWS_COND>[a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return WORD; }
161 [a-zA-Z]+ { yylval.string = strdup(yytext); return WORD; }
162 . { return (int)yytext[0]; }
165 while (yy_start_stack_ptr > 0)