(statement_bytes: &[u8], args: Option<&Node>)
| 150 | } |
| 151 | |
| 152 | fn convert_args_node(statement_bytes: &[u8], args: Option<&Node>) -> Result<Option<Vec<FunctionArg>>, DscError> { |
| 153 | let Some(args) = args else { |
| 154 | return Ok(None); |
| 155 | }; |
| 156 | let mut result = vec![]; |
| 157 | let mut cursor = args.walk(); |
| 158 | for arg in args.named_children(&mut cursor) { |
| 159 | match arg.kind() { |
| 160 | "string" => { |
| 161 | let value = arg.utf8_text(statement_bytes)?; |
| 162 | // Resolve escaped single quotes |
| 163 | result.push(FunctionArg::Value(Value::String(value.to_string().replace("''", "'")))); |
| 164 | }, |
| 165 | "number" => { |
| 166 | let value = arg.utf8_text(statement_bytes)?; |
| 167 | result.push(FunctionArg::Value(Value::Number(Number::from(value.parse::<i32>()?)))); |
| 168 | }, |
| 169 | "boolean" => { |
| 170 | let value = arg.utf8_text(statement_bytes)?; |
| 171 | result.push(FunctionArg::Value(Value::Bool(value.parse::<bool>()?))); |
| 172 | }, |
| 173 | "expression" => { |
| 174 | // TODO: this is recursive, we may want to stop at a specific depth |
| 175 | let expression = Expression::new(statement_bytes, &arg)?; |
| 176 | result.push(FunctionArg::Expression(expression)); |
| 177 | }, |
| 178 | _ => { |
| 179 | return Err(DscError::Parser(t!("parser.functions.unknownArgType", kind = arg.kind()).to_string())); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | Ok(Some(result)) |
| 184 | } |
no test coverage detected