(&mut self, match_node: tree_sitter::Node, input: &str, input_bytes: &[u8])
| 83 | } |
| 84 | |
| 85 | fn parse_match_node(&mut self, match_node: tree_sitter::Node, input: &str, input_bytes: &[u8]) -> Result<(), SshdConfigError> { |
| 86 | let mut criteria_map = Map::new(); |
| 87 | let mut cursor = match_node.walk(); |
| 88 | let mut match_object = Map::new(); |
| 89 | |
| 90 | for child_node in match_node.named_children(&mut cursor) { |
| 91 | if child_node.is_error() { |
| 92 | return Err(SshdConfigError::ParserError(t!("parser.failedToParseNode", input = input).to_string())); |
| 93 | } |
| 94 | |
| 95 | match child_node.kind() { |
| 96 | "comment" => {} |
| 97 | "criteria" => { |
| 98 | Self::parse_match_criteria(child_node, input, input_bytes, &mut criteria_map)?; |
| 99 | } |
| 100 | "keyword" => { |
| 101 | Self::parse_and_insert_keyword(child_node, input, input_bytes, Some(&mut match_object))?; |
| 102 | } |
| 103 | _ => { |
| 104 | return Err(SshdConfigError::ParserError(t!("parser.unknownNodeType", node = child_node.kind()).to_string())); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // Add the match object to the main map |
| 110 | if criteria_map.is_empty() { |
| 111 | return Err(SshdConfigError::ParserError(t!("parser.missingCriteriaInMatch", input = input).to_string())); |
| 112 | } |
| 113 | match_object.insert("criteria".to_string(), Value::Object(criteria_map)); |
| 114 | Self::insert_into_map(&mut self.map, "match", Value::Object(match_object), true)?; |
| 115 | Ok(()) |
| 116 | } |
| 117 | |
| 118 | /// Parse a single match criteria node and insert into the provided criteria map. |
| 119 | /// Example criteria node: "user alice,bob" or "address *.*.0.1" |
no test coverage detected