aboutsummaryrefslogtreecommitdiffstats
path: root/doc/syntax
blob: eaf0bae451d582b2de285b188e05c8b7d1741dbc (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
auto-auto-complete ::= _ program _

program ::= '(' _ value _ body ')'

body ::= [{(multiple | default | unargumented | argumented | variadic | suggestion) _}]

_value ::= __ name | _ value | _ case

value ::= name | variable | case

variable ::= '(' _ "value" __ name _ [{value _}] ')'

case ::= '(' _ "case" {_ a_case} _ ')'

a_case ::= '(' {_ value} _ ')'

multiple ::= '(' _ "multiple" <keyword=_value> [{_ '(' _ <item=anything> _ ')'}] _ ')'
         ==> [{'(' <keyword> ' ' <item>  ')'}]

anything ::= [{_ value | _ '(' anything _ ')'}]

default ::= '(' _ "default" (4-:_ ) _ ')'

unargumented ::= '(' _ "unargumented" (3-:_ (options | complete | desc)) _ ')'

argumented ::= '(' _ "argumented" (6-:_ (options | complete | arg | suggest | files | bind | desc)) _ ')'

variadic ::= '(' _ "variadic" (6-:_ (options | complete | arg | suggest | files | bind | desc)) _ ')'

options ::= '(' _ "options" _value [{_ value}] ')'

complete ::= '(' _ "complete" _value [{_ value}] ')'

arg ::= '(' _ "arg" _value ')'

suggest ::= '(' _ "suggest" _value ')'

files ::= '(' _ "files" _value [{_ value}] ')'
::=  {"-0" | "-a" | "-d" | "-D" | "-f" | "-l" | "-r" | "-b" | "-c" | "-s" | "-S" | "-p"} [{value}]

bind ::= '(' _ "bind" _value ')'

desc ::= '(' _ "desc" _value ')'

suggestion ::= '(' _ "suggestion" _ value {_ a_suggestion} _ ')'

a_suggestion ::= '(' _ (exec | noexec | ls | verbatim | calc) _ ')'

exec ::= 'exec' (__ value | _ any_exec) [{_ value | _ any_exec}]

noexec ::= ls | verbatim

ls ::= 'ls' _value [_ value]

verbatim ::= 'verbatim' _value [{_ value}]

calc ::= 'calc' (__ value | _ any_exec) [{_ value | _ any_exec}]

any_exec ::= '(' _ (exec_sequence | exec_redirect) _ ')'

exec_sequence ::= exec_type (__ value | _ any_exec) [{_ value | _ any_exec}]

exec_type ::= "exec" | "calc" | "pipe" | "fullpipe" | "cat" | "and" | "or"

exec_redirect ::= std_redirect | fd_redirect | std_redirect_fd | fd_redirect_fd

std_redirect ::= input _ any_exec _ value

fd_redirect ::= "fd" _ any_exec _ (number _value | fdnum _ value)

std_redirect_fd ::= input "-fd" _ any_exec _ (number | fdnum)

fd_redirect_fd ::= "fd" _ any_exec _ (number __ number | (number | fdnum) _ fdnum | fdnum _ number)

input ::= "stdin" | "stdout" | "stderr"

fdnum :: = "(" _ input _ ")"

number ::= {"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"}

name ::= {letter | escape | squote | dquote}

letter :: $any ^ ' ' ^ \t ^ \n ^ \r ^ \t ^ '\' ^ \' ^ \"

escape ::= '\' $any

squote ::= \' [{$any ^ '\' ^ \' | escape}] \'

dquote ::= \" [{$any ^ '\' ^ \" | escape}] \"

comment ::= ('#' | ';') [{$any}] \z

__ ::= {' ' | \t | \n | \r | \f | comment}

_ ::= [__]