syntax analysis with simplified shell grammar
+ TODO : bug to fix in lexer.c
This commit is contained in:
45
parsing.txt
45
parsing.txt
@@ -1,3 +1,5 @@
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02
|
||||
|
||||
/* -------------------------------------------------------
|
||||
The grammar symbols
|
||||
------------------------------------------------------- */
|
||||
@@ -8,6 +10,49 @@
|
||||
%token DGREAT // '>>'
|
||||
%token PIPE // '|'
|
||||
|
||||
/* -------------------------------------------------------
|
||||
The Simplified Grammar
|
||||
------------------------------------------------------- */
|
||||
%start program
|
||||
%%
|
||||
pipeline : command
|
||||
| pipe_sequence '|' command
|
||||
;
|
||||
command : cmd_prefix cmd_name cmd_suffix
|
||||
| cmd_prefix cmd_name
|
||||
| cmd_name cmd_suffix
|
||||
| cmd_name
|
||||
;
|
||||
cmd_name : WORD // Apply rule 7a
|
||||
;
|
||||
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
|
||||
;
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------
|
||||
The Grammar
|
||||
------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user