Shell
Sintaxes completas representadas por
Diagrama Sintático - Diagrama de Sintaxe
(
ver convenções
) ou
BNF
(ver
convenções
).
Diagrama Sintático - Diagrama de Sintaxe
|
Diagrama Sintático - Diagrama de Sintaxe e BNF
|
BNF
1
.
complete_command
complete_command
: list separator?
2
.
list
list
: and_or {separator_op and_or}
3
.
and_or
and_or
: pipeline {and_or ('&&' | '||') linebreak pipeline}
4
.
pipeline
pipeline
: '!'? pipe_sequence
5
.
pipe_sequence
pipe_sequence
: command {('|' linebreak) command}
6
.
command
command
: simple_command | compound_command redirect_list? | function_definition
7
.
compound_command
compound_command
: brace_group | subshell | for_clause | case_clause | if_clause | while_clause | until_clause
8
.
subshell
subshell
: '(' compound_list ')'
9
.
compound_list
compound_list
: newline_list? term separator?
10
.
term
term
: and_or {separator and_or}
11
.
for_clause
for_clause
: for name linebreak [in [wordlist] sequential_sep] do_group
12
.
wordlist
wordlist
: wordlist: WORD+
13
.
case_clause
case_clause
: case WORD linebreak in linebreak (case_list|case_list_ns|'') esac
14
.
case_list_ns
case_list_ns
: case_list? case_item_ns
15
.
case_list
case_list
: case_item+
16
.
case_item_ns
case_item_ns
: '('? pattern ')'compound_list? linebreak
17
.
case_item
case_item
: '('? pattern ')' (linebreak|compound_list) ';;' linebreak
18
.
pattern
pattern
: WORD { '|' WORD }
19
.
if_clause
if_clause
: if compound_list then compound_list [{elif compound_list then} else compound_list] fi
20
.
while_clause
while_clause
: while compound_list do_group;
21
.
until_clause
until_clause
: until_clause: until compound_list do_group;
22
.
function_definition
function_definition
: fname '()' linebreak function_body
23
.
function_body
function_body
: compound_command redirect_list?
24
.
fname
fname
: NAME
25
.
brace_group
brace_group
: '{' compound_list '}'
26
.
do_group
do_group
: do compound_list done
27
.
simple_command
simple_command
: cmd_prefix? cmd_name cmd_suffix?
28
.
cmd_name
cmd_name
: WORD
29
.
cmd_prefix
cmd_prefix
: cmd_prefix: (io_redirect | ASSIGNMENT_WORD)+
30
.
cmd_suffix
cmd_suffix
: ( io_redirect | WORD)+
31
.
redirect_list
redirect_list
: io_redirect+
32
.
io_redirect
io_redirect
: IO_NUMBER?( io_file | io_here)
33
.
io_file
io_file
: ('<' | '<&' | '>' | '>&' | '>>' | '<>' | '>|') filename
34
.
filename
filename
: WORD
35
.
io_here
io_here
: ('<<' | '<<-') here_end
36
.
here_end
here_end
: WORD
37
.
newline_list
newline_list
: newline_list? NEWLINE
38
.
linebreak
linebreak
: newline_list | ''
39
.
separator_op
separator_op
: '&' | ';'
40
.
separator
separator
: separator_op linebreak | newline_list
41
.
sequential_sep
sequential_sep
: ';' linebreak | newline_list