summaryrefslogtreecommitdiffstats
path: root/src/parse
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-17 16:50:27 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-17 16:50:27 -0500
commitcbcb6eb53ee65710657b2e058d2bfe8c5837a96d (patch)
tree28ce19373754bb44d9fb43c8489d91da2c9ccd6e /src/parse
parente3250575690f85f7b35c4eae585fbbea106e1cb0 (diff)
downloadnbsh-cbcb6eb53ee65710657b2e058d2bfe8c5837a96d.tar.gz
nbsh-cbcb6eb53ee65710657b2e058d2bfe8c5837a96d.zip
implement else
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/ast.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/parse/ast.rs b/src/parse/ast.rs
index 9d74331..534c87e 100644
--- a/src/parse/ast.rs
+++ b/src/parse/ast.rs
@@ -42,6 +42,7 @@ pub enum Command {
If(Pipeline),
While(Pipeline),
For(String, Vec<Word>),
+ Else(Option<Pipeline>),
End,
}
@@ -70,6 +71,9 @@ impl Command {
list.into_inner().map(Word::build_ast).collect();
Self::For(var.as_str().to_string(), vals)
}
+ Rule::control_else => Self::Else(
+ ty.into_inner().next().map(Pipeline::build_ast),
+ ),
Rule::control_end => Self::End,
_ => unreachable!(),
}