blob: 1ff20c4ae36e7d04932d11fddb14209aba516bc3 (
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
|
bareword_char = @{ !("|" | ";" | "\"" | "'" | WHITESPACE | COMMENT) ~ ANY }
single_string_char = @{ "\\'" | (!"'" ~ ANY) }
double_string_char = @{ "\\\"" | (!"\"" ~ ANY) }
redir_prefix = @{ ASCII_DIGIT* ~ (">>" | ">" | "<") ~ WHITESPACE* }
bareword = @{ bareword_char+ }
single_string = @{ single_string_char+ }
double_string = @{ double_string_char+ }
word = ${
redir_prefix? ~
(bareword |
"'" ~ single_string ~ "'" |
"\"" ~ double_string ~ "\"")
}
exe = ${ word ~ (w ~ word)* }
pipeline = ${ exe ~ (w ~ "|" ~ w ~ exe)* }
commands = ${ pipeline ~ (w ~ ";" ~ w ~ pipeline)* }
line = ${ SOI ~ w ~ commands ~ w ~ EOI }
w = _{ (WHITESPACE | COMMENT)* }
WHITESPACE = _{ (" " | "\t" | "\n") }
COMMENT = _{ "#" ~ ANY* }
|