i3
config_parser.h
Go to the documentation of this file.
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * config_parser.h: config parser-related definitions
8  *
9  */
10 #pragma once
11 
12 #include <config.h>
13 
14 #include <yajl/yajl_gen.h>
15 
16 SLIST_HEAD(variables_head, Variable);
17 extern pid_t config_error_nagbar_pid;
18 
19 struct stack_entry {
20  /* Just a pointer, not dynamically allocated. */
21  const char *identifier;
22  enum {
23  STACK_STR = 0,
25  } type;
26  union {
27  char *str;
28  long num;
29  } val;
30 };
31 
32 struct stack {
33  struct stack_entry stack[10];
34 };
35 
36 struct parser_ctx {
37  bool use_nagbar;
38  bool assume_v4;
39 
40  int state;
42 
43  /* A list which contains the states that lead to the current state, e.g.
44  * INITIAL, WORKSPACE_LAYOUT.
45  * When jumping back to INITIAL, statelist_idx will simply be set to 1
46  * (likewise for other states, e.g. MODE or BAR).
47  * This list is used to process the nearest error token. */
48  int statelist[10];
49  /* NB: statelist_idx points to where the next entry will be inserted */
51 
52  /*******************************************************************************
53  * The (small) stack where identified literals are stored during the parsing
54  * of a single config directive (like $workspace).
55  ******************************************************************************/
56  struct stack *stack;
57 
58  struct variables_head variables;
59 
60  bool has_errors;
61 };
62 
70  struct parser_ctx *ctx;
71 
72  /* The next state to transition to. Passed to the function so that we can
73  * determine the next state as a result of a function call, like
74  * cfg_criteria_pop_state() does. */
76 
77  /* Whether any error happened while processing this config directive. */
78  bool has_errors;
79 };
80 
84 void start_config_error_nagbar(const char *configpath, bool has_errors);
85 
90 void free_variables(struct parser_ctx *ctx);
91 
92 typedef enum {
97 
106 parse_file_result_t parse_file(struct parser_ctx *ctx, const char *f, IncludedFile *included_file);
ConfigResultIR::ctx
struct parser_ctx * ctx
Definition: config_parser.h:70
ConfigResultIR
An intermediate representation of the result of a parse_config call.
Definition: config_parser.h:69
parse_file_result_t
parse_file_result_t
Definition: config_parser.h:92
parser_ctx
Definition: config_parser.h:36
parser_ctx::use_nagbar
bool use_nagbar
Definition: config_parser.h:37
config_error_nagbar_pid
pid_t config_error_nagbar_pid
Definition: config_parser.c:45
parser_ctx::has_errors
bool has_errors
Definition: config_parser.h:60
parser_ctx::variables
struct variables_head variables
Definition: config_parser.h:58
SLIST_HEAD
SLIST_HEAD(variables_head, Variable)
parser_ctx::stack
struct stack * stack
Definition: config_parser.h:56
stack
Definition: config_parser.h:32
PARSE_FILE_SUCCESS
@ PARSE_FILE_SUCCESS
Definition: config_parser.h:94
ConfigResultIR::next_state
int next_state
Definition: config_parser.h:75
start_config_error_nagbar
void start_config_error_nagbar(const char *configpath, bool has_errors)
launch nagbar to indicate errors in the configuration file.
Definition: config_parser.c:746
ctx
static xcb_cursor_context_t * ctx
Definition: xcursor.c:19
parse_file
parse_file_result_t parse_file(struct parser_ctx *ctx, const char *f, IncludedFile *included_file)
Parses the given file by first replacing the variables, then calling parse_config and launching i3-na...
Definition: config_parser.c:853
stack_entry
Definition: config_parser.h:19
parser_ctx::state
int state
Definition: config_parser.h:40
PARSE_FILE_FAILED
@ PARSE_FILE_FAILED
Definition: config_parser.h:93
ConfigResultIR::has_errors
bool has_errors
Definition: config_parser.h:78
stack_entry::type
enum stack_entry::@2 type
parser_ctx::statelist_idx
int statelist_idx
Definition: config_parser.h:50
stack_entry::val
union stack_entry::@3 val
parser_ctx::statelist
int statelist[10]
Definition: config_parser.h:48
stack_entry::identifier
const char * identifier
Definition: config_parser.h:21
IncludedFile
List entry struct for an included file.
Definition: configuration.h:79
stack_entry::STACK_STR
@ STACK_STR
Definition: config_parser.h:23
free_variables
void free_variables(struct parser_ctx *ctx)
Releases the memory of all variables in ctx.
Definition: config_parser.c:837
parser_ctx::current_match
Match current_match
Definition: config_parser.h:41
Variable
Holds a user-assigned variable for parsing the configuration file.
Definition: configuration.h:67
Match
A "match" is a data structure which acts like a mask or expression to match certain windows or not.
Definition: data.h:557
parser_ctx::assume_v4
bool assume_v4
Definition: config_parser.h:38
stack_entry::str
char * str
Definition: config_parser.h:27
PARSE_FILE_CONFIG_ERRORS
@ PARSE_FILE_CONFIG_ERRORS
Definition: config_parser.h:95
stack_entry::STACK_LONG
@ STACK_LONG
Definition: config_parser.h:24
stack_entry::num
long num
Definition: config_parser.h:28