diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-08 17:28:58 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-08 17:28:58 -0500 |
commit | 27934e2a48254b4b948b846680afe213e61fdfc0 (patch) | |
tree | 4de94e29b90e35be9ebc972a099aa34b7443994f /src/shell.pest | |
parent | bfc458a5ce75762624115feaa50cfd3a3edd7bc0 (diff) | |
download | nbsh-27934e2a48254b4b948b846680afe213e61fdfc0.tar.gz nbsh-27934e2a48254b4b948b846680afe213e61fdfc0.zip |
add parsing for control statements
Diffstat (limited to 'src/shell.pest')
-rw-r--r-- | src/shell.pest | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/shell.pest b/src/shell.pest index fce2c11..118ceec 100644 --- a/src/shell.pest +++ b/src/shell.pest @@ -28,7 +28,15 @@ word = ${ exe = ${ word ~ (w ~ word)* } pipeline = ${ exe ~ (w? ~ "|" ~ w? ~ exe)* } -commands = ${ pipeline ~ (w? ~ ";" ~ w? ~ pipeline)* } + +control_if = ${ "if" ~ w ~ pipeline } +control_while = ${ "while" ~ w ~ pipeline } +control_for = ${ "for" ~ w ~ bareword ~ w ~ "in" ~ w ~ pipeline } +control_end = ${ "end" } +control = ${ control_if | control_while | control_for | control_end } + +command = ${ pipeline | control } +commands = ${ command ~ (w? ~ ";" ~ w? ~ command)* } line = ${ SOI ~ w? ~ commands ~ w? ~ EOI } |