Skip to content
Snippets Groups Projects
Commit da9fc260 authored by stratact's avatar stratact Committed by Michael Aaron Murphy
Browse files

Support string concat and concat-head operations

parent bd48a3d3
No related branches found
No related tags found
No related merge requests found
let string = world
echo $string
let string ++= !
echo $string
let string ::= "Hello, "
echo $string
let string1 = Doctor
let string2 = order
echo $string1
echo $string2
let string1 ++= "'s"
let string2 ++= "s"
echo $string1
echo $string2
let string1 ++= " "
let string2 ::= $string1
echo $string2
world
world!
Hello, world!
Doctor
order
Doctor's
orders
Doctor's orders
...@@ -474,9 +474,18 @@ impl Shell { ...@@ -474,9 +474,18 @@ impl Shell {
match lhs { match lhs {
Value::Str(lhs) => { Value::Str(lhs) => {
if let Value::Str(rhs) = rhs { if let Value::Str(rhs) = rhs {
let action = math(&key.kind, operator, &rhs).map_err(|why| why.to_string())?; match operator {
let value = parse(&lhs, &*action).map_err(|why| why.to_string())?; Operator::Concatenate => lhs.push_str(&rhs),
*lhs = value.into(); Operator::ConcatenateHead => {
*lhs = rhs + lhs;
}
_ => {
let action =
math(&key.kind, operator, &rhs).map_err(|why| why.to_string())?;
let value = parse(&lhs, &*action).map_err(|why| why.to_string())?;
*lhs = value.into();
}
}
} }
Ok(()) Ok(())
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment