| 135 | } |
| 136 | |
| 137 | pub fn parse_tools<F>(mut self, fields: &HashMap<&'gc str, Expr<'gc>>, mut f: F) -> Self |
| 138 | where |
| 139 | F: FnMut(&Token<'gc>) -> Option<FnDef>, |
| 140 | { |
| 141 | if let Some(Expr::List { elements, .. }) = fields.get("tools") { |
| 142 | for element in elements { |
| 143 | match element { |
| 144 | Expr::Variable { name, .. } => { |
| 145 | if let Some(fn_def) = f(name) { |
| 146 | self.tools.insert(name.lexeme.to_owned(), fn_def); |
| 147 | } |
| 148 | } |
| 149 | _ => panic!("Expected string literal"), |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | self |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | #[cfg(not(feature = "ai_test"))] |