strings in variables can now be received by get_string_token

and inputs can be directly assigned to a variable
This commit is contained in:
2026-05-26 20:35:57 +01:00
parent f6a95f76bd
commit cc3eca857d
8 changed files with 68 additions and 28 deletions
+20 -2
View File
@@ -44,6 +44,10 @@ pub fn identifier_parse
// Another thing like a choice or an input
Err(_) =>
{
if operator != tokenise::Operator::Assignment // Only assignment is valid here
{
return Err((format!("Unexpected operator: {operator:?} at index {}",sum_index-1),sum_index + 1))
};
let keyword = tokenise::get_keyword_token(tokens,sum_index)
.map_err(|err| (err,sum_index))?;
match keyword.to_lowercase().as_str()
@@ -51,10 +55,24 @@ pub fn identifier_parse
"choice" =>
{
let choice: String;
(sum_index, choice) = keyword_parse::choice_parse(tokens, index+1, happening_queue,rx)
(sum_index, choice) = keyword_parse::choice_parse(tokens, index+1, happening_queue,rx,variables)
.map_err(|err| (err,sum_index+1))?;
variables.insert(identifier.to_owned(), tokenise::Value::String(choice));
}
},
"input" =>
{
api::modify_data(happening_queue, "input".to_string(), String::new(), String::new(), Vec::new());
let input = match rx.recv()
{
Ok((_,input)) => input,
Err(err) =>
{
warn!("Error receiving input from client, defaulting to choice \"\" {err}");
"".to_string()
}
};
variables.insert(identifier.to_owned(), tokenise::Value::String(input));
},
_ =>
{
warn!("Unexpected keyword {keyword}");