echo builtin
+ WIP grammar rules in parsing.txt + test trop_de_pipes.sh
This commit is contained in:
57
parsing.txt
Normal file
57
parsing.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
/* -------------------------------------------------------
|
||||
The grammar symbols
|
||||
------------------------------------------------------- */
|
||||
%token WORD
|
||||
%token LESS // '<'
|
||||
%token GREAT // '>'
|
||||
%token DLESS // '<<'
|
||||
%token DGREAT // '>>'
|
||||
%token PIPE // '|'
|
||||
|
||||
/* -------------------------------------------------------
|
||||
The Grammar
|
||||
------------------------------------------------------- */
|
||||
%start program
|
||||
%%
|
||||
pipeline : pipe_sequence
|
||||
;
|
||||
pipe_sequence : command
|
||||
| pipe_sequence '|' command
|
||||
;
|
||||
command : simple_command
|
||||
;
|
||||
simple_command : cmd_prefix cmd_word cmd_suffix
|
||||
| cmd_prefix cmd_word
|
||||
| cmd_prefix
|
||||
| cmd_name cmd_suffix
|
||||
| cmd_name
|
||||
;
|
||||
cmd_name : WORD /* Apply rule 7a */
|
||||
;
|
||||
cmd_word : WORD /* Apply rule 7b */
|
||||
;
|
||||
cmd_prefix : io_redirect
|
||||
| cmd_prefix io_redirect
|
||||
;
|
||||
cmd_suffix : io_redirect
|
||||
| cmd_suffix io_redirect
|
||||
| WORD
|
||||
| cmd_suffix WORD
|
||||
;
|
||||
io_redirect : io_file
|
||||
| io_here
|
||||
;
|
||||
io_file : '<' filename
|
||||
| LESSAND filename
|
||||
| '>' filename
|
||||
| GREATAND filename
|
||||
| DGREAT filename
|
||||
| LESSGREAT filename
|
||||
| CLOBBER filename
|
||||
;
|
||||
filename : WORD /* Apply rule 2 */
|
||||
;
|
||||
io_here : DLESS here_end
|
||||
;
|
||||
here_end : WORD /* Apply rule 3 */
|
||||
;
|
||||
Reference in New Issue
Block a user