-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.y
47 lines (46 loc) · 1.51 KB
/
grammar.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%token WORD
%token AND OR
%token LESS GREAT DLESS DGREAT
%token PIPE LPAREN RPAREN
/* -------------------------------------------------------
The Grammar
-------------------------------------------------------
*/
%start list
%%
list : pipeline conditional
conditional : AND pipeline conditional
| OR pipeline conditional
| empty
pipeline : command pipeline_null
command : simple_cmd
| subshell subshell_redir
pipeline_null : PIPE pipeline
| empty
subshell : LBRACE list RBRACE
subshell_redir : redirect_list
| empty
simple_cmd : WORD word_null
| cmd_prefix fcmd_prefix
word_null : cmd_suffix
| empty
fcmd_prefix : WORD word_null
| empty
cmd_prefix : io_redirect cmd_prefix_null
cmd_prefix_null : io_redirect cmd_prefix_null
| empty
cmd_suffix : io_redirect cmd_suffix_null
| WORD cmd_suffix_null
cmd_suffix_null : io_redirect cmd_suffix_null
| WORD cmd_suffix_null
| empty
redirect_list : io_redirect redirect_list_null
redirect_list_null : io_redirect redirect_list_null
| empty
io_redirect : io_file
| io_here
io_file : LESS WORD
| GREAT WORD
| DGREAT WORD
io_here : DLESS WORD
%%