]> git.sur5r.net Git - i3/i3/blobdiff - src/cfgparse.l
Add force_xinerama configuration option
[i3/i3] / src / cfgparse.l
index 5a4f47ee82f550a6133d08bea10cf2eeb97dc8b9..dad5a915520dd60bfe10c9577c0587a180b92d27 100644 (file)
@@ -1,13 +1,13 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ */
 %option nounput
 %option noinput
 %option noyy_top_state
 %option stack
 
 %{
-/*
- * vim:ts=4:sw=4:expandtab
- *
- */
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -25,9 +25,9 @@ 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; \
+    context->first_column = yycolumn; \
+    context->last_column = yycolumn+yyleng-1; \
+    yycolumn += yyleng; \
 }
 
 /* macro to first eat whitespace, then expect a string */
@@ -38,12 +38,13 @@ int yycolumn = 1;
 
 %}
 
-EOL    (\r?\n)
+EOL     (\r?\n)
 
 %s WANT_STRING
 %s WANT_QSTRING
 %s BINDSYM_COND
 %s ASSIGN_COND
+%s ASSIGN_TARGET_COND
 %s COLOR_COND
 %s OUTPUT_COND
 %s FOR_WINDOW_COND
@@ -52,28 +53,36 @@ EOL (\r?\n)
 
 %%
 
-       {
-               /* 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);
-               }
-       }
+    {
+        /* 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 = sstrdup(yytext);
+    /* save whole line */
+    context->line_copy = sstrdup(yytext);
 
-       yyless(0);
-       yy_pop_state();
-       yy_set_bol(true);
-       yycolumn = 1;
+    yyless(0);
+    yy_pop_state();
+    yy_set_bol(true);
+    yycolumn = 1;
 }
 
 
 <FOR_WINDOW_COND>"]"            { yy_pop_state(); return ']'; }
+<ASSIGN_COND>"["                {
+                                  /* this is the case for the new assign syntax
+                                   * that uses criteria */
+                                  yy_pop_state();
+                                  yy_push_state(FOR_WINDOW_COND);
+                                  /* afterwards we will be in ASSIGN_TARGET_COND */
+                                  return '[';
+                                }
 <EAT_WHITESPACE>[ \t]*          { yy_pop_state(); }
 <WANT_QSTRING>\"[^\"]+\"        {
                                   yy_pop_state();
@@ -84,9 +93,11 @@ EOL  (\r?\n)
                                   return STR;
                                 }
 <WANT_STRING>[^\n]+             { BEGIN(INITIAL); yylval.string = sstrdup(yytext); return STR; }
-<OUTPUT_COND>[a-zA-Z0-9_-]+ { yylval.string = sstrdup(yytext); return OUTPUT; }
+<OUTPUT_COND>[a-zA-Z0-9_-]+     { yylval.string = sstrdup(yytext); return OUTPUT; }
 ^[ \t]*#[^\n]*                  { return TOKCOMMENT; }
 <COLOR_COND>[0-9a-fA-F]+        { yylval.string = sstrdup(yytext); return HEX; }
+<ASSIGN_TARGET_COND>[ \t]*→[ \t]*     { BEGIN(WANT_STRING); }
+<ASSIGN_TARGET_COND>[ \t]+      { BEGIN(WANT_STRING); }
 [0-9]+                          { yylval.number = atoi(yytext); return NUMBER; }
 mode                            { return TOKMODE; }
 bind                            { yy_push_state(WANT_STRING); yy_push_state(EAT_WHITESPACE); yy_push_state(EAT_WHITESPACE); return TOKBINDCODE; }
@@ -95,16 +106,9 @@ bindsym                         { yy_push_state(BINDSYM_COND); yy_push_state(EAT
 floating_modifier               { BEGIN(INITIAL); return TOKFLOATING_MODIFIER; }
 workspace                       { BEGIN(INITIAL); return TOKWORKSPACE; }
 output                          { yy_push_state(OUTPUT_COND); yy_push_state(EAT_WHITESPACE); return TOKOUTPUT; }
-screen                          {
-                                  /* for compatibility until v3.φ */
-                                  ELOG("Assignments to screens are DEPRECATED and will not work. " \
-                                       "Please replace them with assignments to outputs.\n");
-                                  yy_push_state(OUTPUT_COND); yy_push_state(EAT_WHITESPACE);
-                                  return TOKOUTPUT;
-                                }
 terminal                        { WS_STRING; return TOKTERMINAL; }
 font                            { WS_STRING; return TOKFONT; }
-assign                          { BEGIN(ASSIGN_COND); return TOKASSIGN; }
+assign                          { yy_push_state(ASSIGN_TARGET_COND); yy_push_state(ASSIGN_COND); return TOKASSIGN; }
 set[^\n]*                       { return TOKCOMMENT; }
 ipc-socket                      { WS_STRING; return TOKIPCSOCKET; }
 ipc_socket                      { WS_STRING; return TOKIPCSOCKET; }
@@ -115,10 +119,13 @@ vertical                        { return TOK_VERT; }
 auto                            { return TOK_AUTO; }
 workspace_layout                { return TOK_WORKSPACE_LAYOUT; }
 new_window                      { return TOKNEWWINDOW; }
+new_float                       { return TOKNEWFLOAT; }
 normal                          { return TOK_NORMAL; }
 none                            { return TOK_NONE; }
 1pixel                          { return TOK_1PIXEL; }
 focus_follows_mouse             { return TOKFOCUSFOLLOWSMOUSE; }
+force_focus_wrapping            { return TOK_FORCE_FOCUS_WRAPPING; }
+force_xinerama                  { return TOK_FORCE_XINERAMA; }
 workspace_bar                   { return TOKWORKSPACEBAR; }
 popup_during_fullscreen         { return TOK_POPUP_DURING_FULLSCREEN; }
 ignore                          { return TOK_IGNORE; }
@@ -143,6 +150,7 @@ stack-limit                     { return TOKSTACKLIMIT; }
 cols                            { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; }
 rows                            { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; }
 exec                            { WS_STRING; return TOKEXEC; }
+exec_always                     { WS_STRING; return TOKEXEC_ALWAYS; }
 client.background               { BEGIN(COLOR_COND); yylval.single_color = &config.client.background; return TOKSINGLECOLOR; }
 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; }
@@ -160,9 +168,10 @@ Mode_switch                     { yylval.number = BIND_MODE_SWITCH; return MODIF
 control                         { return TOKCONTROL; }
 ctrl                            { return TOKCONTROL; }
 shift                           { return TOKSHIFT; }
-→                               { return TOKARROW; }
 
 class                           { yy_push_state(WANT_QSTRING); return TOK_CLASS; }
+instance                        { yy_push_state(WANT_QSTRING); return TOK_INSTANCE; }
+window_role                     { yy_push_state(WANT_QSTRING); return TOK_WINDOW_ROLE; }
 id                              { yy_push_state(WANT_QSTRING); return TOK_ID; }
 con_id                          { yy_push_state(WANT_QSTRING); return TOK_CON_ID; }
 con_mark                        { yy_push_state(WANT_QSTRING); return TOK_MARK; }
@@ -174,27 +183,29 @@ title                           { yy_push_state(WANT_QSTRING); return TOK_TITLE;
                                   BEGIN(INITIAL);
                                   yy_push_state(BUFFER_LINE);
                                 }
-<BINDSYM_COND>[ \t]+           { BEGIN(WANT_STRING); }
-<OUTPUT_COND>[ \t]+         { BEGIN(WANT_STRING); }
+<BINDSYM_COND>[ \t]+            { BEGIN(WANT_STRING); }
+<OUTPUT_COND>[ \t]+             { BEGIN(WANT_STRING); }
 [ \t]+                          { /* ignore whitespace */ ; }
 \"[^\"]+\"                      {
                                   /* if ASSIGN_COND then */
-                                  BEGIN(INITIAL);
+                                  if (yy_start_stack_ptr > 0)
+                                      yy_pop_state();
+                                  else BEGIN(INITIAL);
                                   /* yylval will be the string, but without quotes */
                                   char *copy = sstrdup(yytext+1);
                                   copy[strlen(copy)-1] = '\0';
                                   yylval.string = copy;
                                   return QUOTEDSTRING;
                                 }
-<ASSIGN_COND>[^ \t]+            { BEGIN(INITIAL); yylval.string = sstrdup(yytext); return STR_NG; }
-<BINDSYM_COND>[a-zA-Z0-9_]+ { yylval.string = sstrdup(yytext); return WORD; }
+<ASSIGN_COND>[^ \t\"\[]+        { BEGIN(ASSIGN_TARGET_COND); yylval.string = sstrdup(yytext); return STR_NG; }
+<BINDSYM_COND>[a-zA-Z0-9_]+     { yylval.string = sstrdup(yytext); return WORD; }
 [a-zA-Z]+                       { yylval.string = sstrdup(yytext); return WORD; }
 .                               { return (int)yytext[0]; }
 
 <<EOF>> {
-        while (yy_start_stack_ptr > 0)
-                yy_pop_state();
-        yyterminate();
+    while (yy_start_stack_ptr > 0)
+        yy_pop_state();
+    yyterminate();
 }
 
 %%