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