]> git.sur5r.net Git - i3/i3/blob - parser-specs/config.spec
Made syntax of syntax descriptions consistent:
[i3/i3] / parser-specs / config.spec
1 # vim:ts=2:sw=2:expandtab
2 #
3 # i3 - an improved dynamic tiling window manager
4 # © 2009 Michael Stapelberg and contributors (see also: LICENSE)
5 #
6 # parser-specs/config.spec: Specification file for generate-command-parser.pl
7 # which will generate the appropriate header files for our C parser.
8 #
9 # Use :source highlighting.vim in vim to get syntax highlighting
10 # for this file.
11
12 # TODO: should we implement an include statement for the criteria part so we DRY?
13
14 state INITIAL:
15   # We have an end token here for all the commands which just call some
16   # function without using an explicit 'end' token.
17   end ->
18   error ->
19   '#'                                      -> IGNORE_LINE
20   'set'                                    -> IGNORE_LINE
21   bindtype = 'bindsym', 'bindcode', 'bind' -> BINDING
22   'bar'                                    -> BARBRACE
23   'font'                                   -> FONT
24   'mode'                                   -> MODENAME
25   'floating_minimum_size'                  -> FLOATING_MINIMUM_SIZE_WIDTH
26   'floating_maximum_size'                  -> FLOATING_MAXIMUM_SIZE_WIDTH
27   'floating_modifier'                      -> FLOATING_MODIFIER
28   'default_orientation'                    -> DEFAULT_ORIENTATION
29   'workspace_layout'                       -> WORKSPACE_LAYOUT
30   windowtype = 'new_window', 'new_float'   -> NEW_WINDOW
31   'hide_edge_borders'                      -> HIDE_EDGE_BORDERS
32   'for_window'                             -> FOR_WINDOW
33   'assign'                                 -> ASSIGN
34   'no_focus'                               -> NO_FOCUS
35   'focus_follows_mouse'                    -> FOCUS_FOLLOWS_MOUSE
36   'mouse_warping'                          -> MOUSE_WARPING
37   'force_focus_wrapping'                   -> FORCE_FOCUS_WRAPPING
38   'force_xinerama', 'force-xinerama'       -> FORCE_XINERAMA
39   'workspace_auto_back_and_forth'          -> WORKSPACE_BACK_AND_FORTH
40   'fake_outputs', 'fake-outputs'           -> FAKE_OUTPUTS
41   'force_display_urgency_hint'             -> FORCE_DISPLAY_URGENCY_HINT
42   'focus_on_window_activation'             -> FOCUS_ON_WINDOW_ACTIVATION
43   'show_marks'                             -> SHOW_MARKS
44   'workspace'                              -> WORKSPACE
45   'ipc_socket', 'ipc-socket'               -> IPC_SOCKET
46   'restart_state'                          -> RESTART_STATE
47   'popup_during_fullscreen'                -> POPUP_DURING_FULLSCREEN
48   exectype = 'exec_always', 'exec'         -> EXEC
49   colorclass = 'client.background'
50       -> COLOR_SINGLE
51   colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
52       -> COLOR_BORDER
53
54 # We ignore comments and 'set' lines (variables).
55 state IGNORE_LINE:
56   line
57       -> INITIAL
58
59 # floating_minimum_size <width> x <height>
60 state FLOATING_MINIMUM_SIZE_WIDTH:
61   width = number
62       -> FLOATING_MINIMUM_SIZE_X
63
64 state FLOATING_MINIMUM_SIZE_X:
65   'x'
66       -> FLOATING_MINIMUM_SIZE_HEIGHT
67
68 state FLOATING_MINIMUM_SIZE_HEIGHT:
69   height = number
70       -> call cfg_floating_minimum_size(&width, &height)
71
72 # floating_maximum_size <width> x <height>
73 state FLOATING_MAXIMUM_SIZE_WIDTH:
74   width = number
75       -> FLOATING_MAXIMUM_SIZE_X
76
77 state FLOATING_MAXIMUM_SIZE_X:
78   'x'
79       -> FLOATING_MAXIMUM_SIZE_HEIGHT
80
81 state FLOATING_MAXIMUM_SIZE_HEIGHT:
82   height = number
83       -> call cfg_floating_maximum_size(&width, &height)
84
85 # floating_modifier <modifier>
86 state FLOATING_MODIFIER:
87   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl'
88       ->
89   '+'
90       ->
91   end
92       -> call cfg_floating_modifier($modifiers)
93
94 # default_orientation <horizontal|vertical|auto>
95 state DEFAULT_ORIENTATION:
96   orientation = 'horizontal', 'vertical', 'auto'
97       -> call cfg_default_orientation($orientation)
98
99 # workspace_layout <default|stacking|tabbed>
100 state WORKSPACE_LAYOUT:
101   layout = 'default', 'stacking', 'stacked', 'tabbed'
102       -> call cfg_workspace_layout($layout)
103
104 # new_window <normal|1pixel|none>
105 # new_float <normal|1pixel|none>
106 state NEW_WINDOW:
107   border = 'normal', 'pixel'
108       -> NEW_WINDOW_PIXELS
109   border = '1pixel', 'none'
110       -> call cfg_new_window($windowtype, $border, -1)
111
112 state NEW_WINDOW_PIXELS:
113   end
114       -> call cfg_new_window($windowtype, $border, 2)
115   width = number
116       -> NEW_WINDOW_PIXELS_PX
117
118 state NEW_WINDOW_PIXELS_PX:
119   'px'
120       ->
121   end
122       -> call cfg_new_window($windowtype, $border, &width)
123
124 # hide_edge_borders <none|vertical|horizontal|both>
125 # also hide_edge_borders <bool> for compatibility
126 state HIDE_EDGE_BORDERS:
127   hide_borders = 'none', 'vertical', 'horizontal', 'both'
128       -> call cfg_hide_edge_borders($hide_borders)
129   hide_borders = '1', 'yes', 'true', 'on', 'enable', 'active'
130       -> call cfg_hide_edge_borders($hide_borders)
131
132 # for_window <criteria> command
133 state FOR_WINDOW:
134   '['
135       -> call cfg_criteria_init(FOR_WINDOW_COMMAND); CRITERIA
136
137 state FOR_WINDOW_COMMAND:
138   command = string
139       -> call cfg_for_window($command)
140
141 # assign <criteria> [→] workspace
142 state ASSIGN:
143   '['
144       -> call cfg_criteria_init(ASSIGN_WORKSPACE); CRITERIA
145
146 state ASSIGN_WORKSPACE:
147   '→'
148       ->
149   workspace = string
150       -> call cfg_assign($workspace)
151
152 # no_focus <criteria>
153 state NO_FOCUS:
154   '['
155       -> call cfg_criteria_init(NO_FOCUS_END); CRITERIA
156
157 state NO_FOCUS_END:
158   end
159       -> call cfg_no_focus()
160
161 # Criteria: Used by for_window and assign.
162 state CRITERIA:
163   ctype = 'class'       -> CRITERION
164   ctype = 'instance'    -> CRITERION
165   ctype = 'window_role' -> CRITERION
166   ctype = 'con_id'      -> CRITERION
167   ctype = 'id'          -> CRITERION
168   ctype = 'window_type' -> CRITERION
169   ctype = 'con_mark'    -> CRITERION
170   ctype = 'title'       -> CRITERION
171   ctype = 'urgent'      -> CRITERION
172   ']'
173       -> call cfg_criteria_pop_state()
174
175 state CRITERION:
176   '=' -> CRITERION_STR
177
178 state CRITERION_STR:
179   cvalue = word
180       -> call cfg_criteria_add($ctype, $cvalue); CRITERIA
181
182 # focus_follows_mouse bool
183 state FOCUS_FOLLOWS_MOUSE:
184   value = word
185       -> call cfg_focus_follows_mouse($value)
186
187 # mouse_warping warping_t
188 state MOUSE_WARPING:
189   value = 'none', 'output'
190       -> call cfg_mouse_warping($value)
191
192 # force_focus_wrapping
193 state FORCE_FOCUS_WRAPPING:
194   value = word
195       -> call cfg_force_focus_wrapping($value)
196
197 # force_xinerama
198 state FORCE_XINERAMA:
199   value = word
200       -> call cfg_force_xinerama($value)
201
202 # workspace_back_and_forth
203 state WORKSPACE_BACK_AND_FORTH:
204   value = word
205       -> call cfg_workspace_back_and_forth($value)
206
207
208 # fake_outputs (for testcases)
209 state FAKE_OUTPUTS:
210   outputs = string
211       -> call cfg_fake_outputs($outputs)
212
213 # force_display_urgency_hint <timeout> ms
214 state FORCE_DISPLAY_URGENCY_HINT:
215   duration_ms = number
216       -> FORCE_DISPLAY_URGENCY_HINT_MS
217
218 # show_marks
219 state SHOW_MARKS:
220   value = word
221       -> call cfg_show_marks($value)
222
223 state FORCE_DISPLAY_URGENCY_HINT_MS:
224   'ms'
225       ->
226   end
227       -> call cfg_force_display_urgency_hint(&duration_ms)
228
229 # focus_on_window_activation <smart|urgent|focus|none>
230 state FOCUS_ON_WINDOW_ACTIVATION:
231   mode = word
232       -> call cfg_focus_on_window_activation($mode)
233
234 # workspace <workspace> output <output>
235 state WORKSPACE:
236   workspace = word
237     -> WORKSPACE_OUTPUT
238
239 state WORKSPACE_OUTPUT:
240   'output'
241       -> WORKSPACE_OUTPUT_STR
242
243 state WORKSPACE_OUTPUT_STR:
244   output = word
245       -> call cfg_workspace($workspace, $output)
246
247 # ipc-socket <path>
248 state IPC_SOCKET:
249   path = string
250       -> call cfg_ipc_socket($path)
251
252 # restart_state <path> (for testcases)
253 state RESTART_STATE:
254   path = string
255       -> call cfg_restart_state($path)
256
257 # popup_during_fullscreen
258 state POPUP_DURING_FULLSCREEN:
259   value = 'ignore', 'leave_fullscreen', 'smart'
260       -> call cfg_popup_during_fullscreen($value)
261
262 # client.background <hexcolor>
263 state COLOR_SINGLE:
264   color = word
265       -> call cfg_color_single($colorclass, $color)
266
267 # colorclass border background text indicator
268 state COLOR_BORDER:
269   border = word
270       -> COLOR_BACKGROUND
271
272 state COLOR_BACKGROUND:
273   background = word
274       -> COLOR_TEXT
275
276 state COLOR_TEXT:
277   text = word
278       -> COLOR_INDICATOR
279
280 state COLOR_INDICATOR:
281   indicator = word
282       -> call cfg_color($colorclass, $border, $background, $text, $indicator)
283   end
284       -> call cfg_color($colorclass, $border, $background, $text, NULL)
285
286 # <exec|exec_always> [--no-startup-id] command
287 state EXEC:
288   no_startup_id = '--no-startup-id'
289       ->
290   command = string
291       -> call cfg_exec($exectype, $no_startup_id, $command)
292
293 # font font
294 state FONT:
295   font = string
296       -> call cfg_font($font)
297
298 # bindsym/bindcode
299 state BINDING:
300   release = '--release'
301       ->
302   border = '--border'
303       ->
304   whole_window = '--whole-window'
305       ->
306   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', '$mod'
307       ->
308   '+'
309       ->
310   key = word
311       -> BINDCOMMAND
312
313 state BINDCOMMAND:
314   release = '--release'
315       ->
316   border = '--border'
317       ->
318   whole_window = '--whole-window'
319       ->
320   command = string
321       -> call cfg_binding($bindtype, $modifiers, $key, $release, $border, $whole_window, $command)
322
323 ################################################################################
324 # Mode configuration
325 ################################################################################
326
327 state MODENAME:
328   modename = word
329       -> call cfg_enter_mode($modename); MODEBRACE
330
331 state MODEBRACE:
332   end
333       ->
334   '{'
335       -> MODE
336
337 state MODE:
338   end ->
339   error ->
340   '#' -> MODE_IGNORE_LINE
341   'set' -> MODE_IGNORE_LINE
342   bindtype = 'bindsym', 'bindcode', 'bind'
343       -> MODE_BINDING
344   '}'
345       -> INITIAL
346
347 # We ignore comments and 'set' lines (variables).
348 state MODE_IGNORE_LINE:
349   line
350       -> MODE
351
352 state MODE_BINDING:
353   release = '--release'
354       ->
355   border = '--border'
356       ->
357   whole_window = '--whole-window'
358       ->
359   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', '$mod'
360       ->
361   '+'
362       ->
363   key = word
364       -> MODE_BINDCOMMAND
365
366 state MODE_BINDCOMMAND:
367   release = '--release'
368       ->
369   border = '--border'
370       ->
371   whole_window = '--whole-window'
372       ->
373   command = string
374       -> call cfg_mode_binding($bindtype, $modifiers, $key, $release, $border, $whole_window, $command); MODE
375
376 ################################################################################
377 # Bar configuration (i3bar)
378 ################################################################################
379
380 state BARBRACE:
381   end
382       ->
383   '{'
384       -> BAR
385
386 state BAR:
387   end ->
388   error ->
389   '#' -> BAR_IGNORE_LINE
390   'set' -> BAR_IGNORE_LINE
391   'i3bar_command'          -> BAR_BAR_COMMAND
392   'status_command'         -> BAR_STATUS_COMMAND
393   'socket_path'            -> BAR_SOCKET_PATH
394   'mode'                   -> BAR_MODE
395   'hidden_state'           -> BAR_HIDDEN_STATE
396   'id'                     -> BAR_ID
397   'modifier'               -> BAR_MODIFIER
398   'wheel_up_cmd'           -> BAR_WHEEL_UP_CMD
399   'wheel_down_cmd'         -> BAR_WHEEL_DOWN_CMD
400   'position'               -> BAR_POSITION
401   'output'                 -> BAR_OUTPUT
402   'tray_output'            -> BAR_TRAY_OUTPUT
403   'font'                   -> BAR_FONT
404   'separator_symbol'       -> BAR_SEPARATOR_SYMBOL
405   'binding_mode_indicator' -> BAR_BINDING_MODE_INDICATOR
406   'workspace_buttons'      -> BAR_WORKSPACE_BUTTONS
407   'strip_workspace_numbers' -> BAR_STRIP_WORKSPACE_NUMBERS
408   'verbose'                -> BAR_VERBOSE
409   'colors'                 -> BAR_COLORS_BRACE
410   '}'
411       -> call cfg_bar_finish(); INITIAL
412
413 # We ignore comments and 'set' lines (variables).
414 state BAR_IGNORE_LINE:
415   line
416       -> BAR
417
418 state BAR_BAR_COMMAND:
419   command = string
420       -> call cfg_bar_i3bar_command($command); BAR
421
422 state BAR_STATUS_COMMAND:
423   command = string
424       -> call cfg_bar_status_command($command); BAR
425
426 state BAR_SOCKET_PATH:
427   path = string
428       -> call cfg_bar_socket_path($path); BAR
429
430 state BAR_MODE:
431   mode = 'dock', 'hide', 'invisible'
432       -> call cfg_bar_mode($mode); BAR
433
434 state BAR_HIDDEN_STATE:
435   hidden_state = 'hide', 'show'
436       -> call cfg_bar_hidden_state($hidden_state); BAR
437
438 state BAR_ID:
439   bar_id = word
440       -> call cfg_bar_id($bar_id); BAR
441
442 state BAR_MODIFIER:
443   modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
444       -> call cfg_bar_modifier($modifier); BAR
445
446 state BAR_WHEEL_UP_CMD:
447   command = string
448       -> call cfg_bar_wheel_up_cmd($command); BAR
449
450 state BAR_WHEEL_DOWN_CMD:
451   command = string
452       -> call cfg_bar_wheel_down_cmd($command); BAR
453
454 state BAR_POSITION:
455   position = 'top', 'bottom'
456       -> call cfg_bar_position($position); BAR
457
458 state BAR_OUTPUT:
459   output = string
460       -> call cfg_bar_output($output); BAR
461
462 state BAR_TRAY_OUTPUT:
463   output = word
464       -> call cfg_bar_tray_output($output); BAR
465
466 state BAR_FONT:
467   font = string
468       -> call cfg_bar_font($font); BAR
469
470 state BAR_SEPARATOR_SYMBOL:
471   separator = string
472       -> call cfg_bar_separator_symbol($separator); BAR
473
474 state BAR_BINDING_MODE_INDICATOR:
475   value = word
476       -> call cfg_bar_binding_mode_indicator($value); BAR
477
478 state BAR_WORKSPACE_BUTTONS:
479   value = word
480       -> call cfg_bar_workspace_buttons($value); BAR
481
482 state BAR_STRIP_WORKSPACE_NUMBERS:
483   value = word
484       -> call cfg_bar_strip_workspace_numbers($value); BAR
485
486 state BAR_VERBOSE:
487   value = word
488       -> call cfg_bar_verbose($value); BAR
489
490 state BAR_COLORS_BRACE:
491   end
492       ->
493   '{'
494       -> BAR_COLORS
495
496 state BAR_COLORS:
497   end ->
498   '#' -> BAR_COLORS_IGNORE_LINE
499   'set' -> BAR_COLORS_IGNORE_LINE
500   colorclass = 'background', 'statusline', 'separator'
501       -> BAR_COLORS_SINGLE
502   colorclass = 'focused_workspace', 'active_workspace', 'inactive_workspace', 'urgent_workspace'
503       -> BAR_COLORS_BORDER
504   '}'
505       -> BAR
506
507 # We ignore comments and 'set' lines (variables).
508 state BAR_COLORS_IGNORE_LINE:
509   line
510       -> BAR_COLORS
511
512 state BAR_COLORS_SINGLE:
513   color = word
514       -> call cfg_bar_color_single($colorclass, $color); BAR_COLORS
515
516 state BAR_COLORS_BORDER:
517   border = word
518       -> BAR_COLORS_BACKGROUND
519
520 state BAR_COLORS_BACKGROUND:
521   background = word
522       -> BAR_COLORS_TEXT
523
524 state BAR_COLORS_TEXT:
525   end
526       -> call cfg_bar_color($colorclass, $border, $background, NULL); BAR_COLORS
527   text = word
528       -> call cfg_bar_color($colorclass, $border, $background, $text); BAR_COLORS