diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-10 03:33:43 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-10 03:33:43 -0500 |
commit | b8ab245fa35143ec6c1884d7aa685f25a5213940 (patch) | |
tree | e2ccaa44017560065c35ee850788e688f16b76e5 /src/shell.pest | |
parent | feb02a8048a31a46ab57fa268d3f22b40af73c61 (diff) | |
download | nbsh-b8ab245fa35143ec6c1884d7aa685f25a5213940.tar.gz nbsh-b8ab245fa35143ec6c1884d7aa685f25a5213940.zip |
parse alternations
Diffstat (limited to 'src/shell.pest')
-rw-r--r-- | src/shell.pest | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/shell.pest b/src/shell.pest index 393e60e..d09ccbc 100644 --- a/src/shell.pest +++ b/src/shell.pest @@ -3,7 +3,7 @@ escape_char = @{ "\\" ~ ANY } bareword_char = @{ escape_char | - !("|" | ";" | "\"" | "'" | "$" | WHITESPACE | COMMENT) ~ ANY + !("|" | ";" | "\"" | "'" | "$" | "{" | WHITESPACE | COMMENT) ~ ANY } single_string_char = @{ basic_escape_char | (!"'" ~ ANY) } double_string_char = @{ escape_char | (!"\"" ~ ANY) } @@ -21,7 +21,19 @@ bareword = @{ bareword_char+ } single_string = @{ single_string_char+ } double_string = @{ double_string_char+ } +alternation_bareword_char = @{ !("," | "}") ~ bareword_char } +alternation_bareword = @{ alternation_bareword_char+ } +alternation_word_part = ${ + var | + alternation_bareword | + "'" ~ single_string ~ "'" | + "\"" ~ (var | double_string)+ ~ "\"" +} +alternation_word = ${ alternation_word_part* } +alternation = ${ "{" ~ alternation_word ~ ("," ~ alternation_word)* ~ "}" } + word_part = ${ + alternation | var | bareword | "'" ~ single_string ~ "'" | |