2009-09-29 22:47:37 +02:00
|
|
|
%option nounput
|
|
|
|
%option noinput
|
2010-02-13 19:42:54 +01:00
|
|
|
%option noyy_top_state
|
|
|
|
%option stack
|
2009-09-29 22:47:37 +02:00
|
|
|
|
2009-09-13 14:16:39 +02:00
|
|
|
%{
|
2009-09-27 17:01:06 +02:00
|
|
|
/*
|
|
|
|
* vim:ts=8:expandtab
|
|
|
|
*
|
|
|
|
*/
|
2009-09-13 14:16:39 +02:00
|
|
|
#include <stdio.h>
|
2009-09-26 13:30:32 +02:00
|
|
|
#include <string.h>
|
2009-09-13 14:16:39 +02:00
|
|
|
#include "cfgparse.tab.h"
|
|
|
|
#include <xcb/xcb.h>
|
|
|
|
|
2009-09-13 14:54:27 +02:00
|
|
|
#include "data.h"
|
2009-09-13 18:40:35 +02:00
|
|
|
#include "config.h"
|
2010-02-13 19:42:54 +01:00
|
|
|
#include "log.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
int yycolumn = 1;
|
|
|
|
|
|
|
|
#define YY_DECL int yylex (struct context *context)
|
|
|
|
|
|
|
|
#define YY_USER_ACTION { \
|
|
|
|
context->first_column = yycolumn; \
|
|
|
|
context->last_column = yycolumn+yyleng-1; \
|
|
|
|
yycolumn += yyleng; \
|
|
|
|
}
|
|
|
|
|
2009-09-13 14:16:39 +02:00
|
|
|
%}
|
|
|
|
|
2010-02-13 19:42:54 +01:00
|
|
|
EOL (\r?\n)
|
|
|
|
|
|
|
|
%s BIND_COND
|
|
|
|
%s BINDSYM_COND
|
|
|
|
%s BIND_AWS_COND
|
|
|
|
%s BINDSYM_AWS_COND
|
|
|
|
%s BIND_A2WS_COND
|
|
|
|
%s ASSIGN_COND
|
|
|
|
%s COLOR_COND
|
|
|
|
%s SCREEN_COND
|
|
|
|
%s SCREEN_AWS_COND
|
|
|
|
%x BUFFER_LINE
|
2009-09-13 14:16:39 +02:00
|
|
|
|
|
|
|
%%
|
2010-02-13 19:42:54 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
/* This is called when a new line is lexed. We only want the
|
|
|
|
* first line to match to go into state BUFFER_LINE */
|
|
|
|
if (context->line_number == 0) {
|
|
|
|
context->line_number = 1;
|
|
|
|
BEGIN(INITIAL);
|
|
|
|
yy_push_state(BUFFER_LINE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
<BUFFER_LINE>^[^\r\n]*/{EOL}? {
|
|
|
|
/* save whole line */
|
|
|
|
context->line_copy = strdup(yytext);
|
|
|
|
|
|
|
|
yyless(0);
|
|
|
|
yy_pop_state();
|
|
|
|
yy_set_bol(true);
|
|
|
|
yycolumn = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-13 18:40:35 +02:00
|
|
|
<BIND_A2WS_COND>[^\n]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR; }
|
2009-09-27 17:00:37 +02:00
|
|
|
^[ \t]*#[^\n]* { return TOKCOMMENT; }
|
2009-09-13 18:40:35 +02:00
|
|
|
<COLOR_COND>[0-9a-fA-F]+ { yylval.string = strdup(yytext); return HEX; }
|
2009-09-19 19:34:02 +02:00
|
|
|
[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
|
2009-09-27 17:02:13 +02:00
|
|
|
mode { return TOKMODE; }
|
2009-09-13 18:40:35 +02:00
|
|
|
bind { BEGIN(BIND_COND); return TOKBIND; }
|
2009-09-29 11:32:57 +02:00
|
|
|
bindsym { BEGIN(BINDSYM_COND); return TOKBINDSYM; }
|
2010-01-08 18:56:01 +01:00
|
|
|
floating_modifier { BEGIN(INITIAL); return TOKFLOATING_MODIFIER; }
|
2009-09-13 18:40:35 +02:00
|
|
|
workspace { BEGIN(INITIAL); return TOKWORKSPACE; }
|
|
|
|
screen { BEGIN(SCREEN_COND); return TOKSCREEN; }
|
|
|
|
terminal { BEGIN(BIND_AWS_COND); return TOKTERMINAL; }
|
|
|
|
font { BEGIN(BIND_AWS_COND); return TOKFONT; }
|
|
|
|
assign { BEGIN(ASSIGN_COND); return TOKASSIGN; }
|
2009-09-13 21:32:58 +02:00
|
|
|
set[^\n]* { return TOKCOMMENT; }
|
2009-09-13 18:40:35 +02:00
|
|
|
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
2009-09-27 20:44:24 +02:00
|
|
|
ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
2009-09-27 23:08:27 +02:00
|
|
|
new_container { return TOKNEWCONTAINER; }
|
2009-11-08 12:43:01 +01:00
|
|
|
new_window { return TOKNEWWINDOW; }
|
2010-01-26 12:10:48 +01:00
|
|
|
focus_follows_mouse { return TOKFOCUSFOLLOWSMOUSE; }
|
2009-09-27 23:08:27 +02:00
|
|
|
default { yylval.number = MODE_DEFAULT; return TOKCONTAINERMODE; }
|
|
|
|
stacking { yylval.number = MODE_STACK; return TOKCONTAINERMODE; }
|
|
|
|
tabbed { yylval.number = MODE_TABBED; return TOKCONTAINERMODE; }
|
|
|
|
stack-limit { return TOKSTACKLIMIT; }
|
|
|
|
cols { yylval.number = STACK_LIMIT_COLS; return TOKSTACKLIMIT; }
|
|
|
|
rows { yylval.number = STACK_LIMIT_ROWS; return TOKSTACKLIMIT; }
|
2009-09-13 18:40:35 +02:00
|
|
|
exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
|
|
|
|
client.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
|
|
|
|
client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
|
|
|
|
client.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
|
|
|
|
client.urgent { BEGIN(COLOR_COND); yylval.color = &config.client.urgent; return TOKCOLOR; }
|
2009-10-23 23:13:38 +02:00
|
|
|
bar.focused { BEGIN(COLOR_COND); yylval.color = &config.bar.focused; return TOKCOLOR; }
|
|
|
|
bar.unfocused { BEGIN(COLOR_COND); yylval.color = &config.bar.unfocused; return TOKCOLOR; }
|
|
|
|
bar.urgent { BEGIN(COLOR_COND); yylval.color = &config.bar.urgent; return TOKCOLOR; }
|
2009-09-13 18:40:35 +02:00
|
|
|
Mod1 { yylval.number = BIND_MOD1; return MODIFIER; }
|
|
|
|
Mod2 { yylval.number = BIND_MOD2; return MODIFIER; }
|
|
|
|
Mod3 { yylval.number = BIND_MOD3; return MODIFIER; }
|
|
|
|
Mod4 { yylval.number = BIND_MOD4; return MODIFIER; }
|
|
|
|
Mod5 { yylval.number = BIND_MOD5; return MODIFIER; }
|
2009-09-19 19:05:15 +02:00
|
|
|
Mode_switch { yylval.number = BIND_MODE_SWITCH; return MODIFIER; }
|
2009-09-13 18:40:35 +02:00
|
|
|
control { return TOKCONTROL; }
|
2009-11-12 20:28:09 +01:00
|
|
|
ctrl { return TOKCONTROL; }
|
2009-09-13 18:40:35 +02:00
|
|
|
shift { return TOKSHIFT; }
|
|
|
|
→ { return TOKARROW; }
|
2010-02-13 19:42:54 +01:00
|
|
|
{EOL} {
|
|
|
|
FREE(context->line_copy);
|
|
|
|
context->line_number++;
|
|
|
|
yy_push_state(BUFFER_LINE);
|
|
|
|
}
|
2009-09-13 18:40:35 +02:00
|
|
|
<SCREEN_AWS_COND>x { return (int)yytext[0]; }
|
|
|
|
<BIND_COND>[ \t]+ { BEGIN(BIND_AWS_COND); return WHITESPACE; }
|
2009-09-29 11:32:57 +02:00
|
|
|
<BINDSYM_COND>[ \t]+ { BEGIN(BINDSYM_AWS_COND); return WHITESPACE; }
|
2009-09-13 18:40:35 +02:00
|
|
|
<BIND_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
2009-09-29 11:32:57 +02:00
|
|
|
<BINDSYM_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
2009-09-13 18:40:35 +02:00
|
|
|
<SCREEN_COND>[ \t]+ { BEGIN(SCREEN_AWS_COND); return WHITESPACE; }
|
|
|
|
<SCREEN_AWS_COND>[ \t]+ { BEGIN(BIND_A2WS_COND); return WHITESPACE; }
|
|
|
|
[ \t]+ { return WHITESPACE; }
|
|
|
|
\"[^\"]+\" {
|
|
|
|
/* if ASSIGN_COND then */
|
|
|
|
BEGIN(INITIAL);
|
|
|
|
/* yylval will be the string, but without quotes */
|
|
|
|
char *copy = strdup(yytext+1);
|
|
|
|
copy[strlen(copy)-1] = '\0';
|
|
|
|
yylval.string = copy;
|
|
|
|
return QUOTEDSTRING;
|
|
|
|
}
|
|
|
|
<ASSIGN_COND>[^ \t]+ { BEGIN(INITIAL); yylval.string = strdup(yytext); return STR_NG; }
|
2009-11-20 15:33:38 +01:00
|
|
|
<BINDSYM_AWS_COND>[a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return WORD; }
|
2009-09-13 18:40:35 +02:00
|
|
|
[a-zA-Z]+ { yylval.string = strdup(yytext); return WORD; }
|
|
|
|
. { return (int)yytext[0]; }
|
2010-02-13 19:42:54 +01:00
|
|
|
|
|
|
|
<<EOF>> {
|
|
|
|
while (yy_start_stack_ptr > 0)
|
|
|
|
yy_pop_state();
|
|
|
|
yyterminate();
|
|
|
|
}
|
|
|
|
|
2009-09-13 14:16:39 +02:00
|
|
|
%%
|