-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGrammar
More file actions
42 lines (36 loc) · 985 Bytes
/
Grammar
File metadata and controls
42 lines (36 loc) · 985 Bytes
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
/* -------------------------------------------------------
The grammar symbols
------------------------------------------------------- */
%token WORD
%token NEWLINE
%token IO_NUMBER
/* The following are the operators */
%token PIPE SEMI AMP LESS GREAT
/* '|' ';' '&' '<' '>' */
%token DLESS DGREAT LESSAND GREATAND
/* '<<' '>>' '<&' '>&' */
/* -------------------------------------------------------
The Grammar
------------------------------------------------------- */
%start program
%%
program : complete_command...
;
complete_command: pipe_sequence... [separator_op]
;
pipe_sequence : simple_command [PIPE]
;
simple_command : WORD... [io_redirect...]
;
io_redirect : [IO_NUMBER] (io_file | io_here)
;
io_file : (LESS | LESSAMP | GREAT | GREATAMP | DGREAT) filename
;
filename : WORD
;
io_here : DLESS here_end
;
here_end : WORD
;
separator_op : (AMP | SEMI)
;