@@ -8,14 +8,7 @@ use tracing::debug;
88use tree_sitter:: Parser ;
99
1010use crate :: error:: SshdConfigError ;
11- use crate :: metadata:: { MULTI_ARG_KEYWORDS_COMMA_SEP , MULTI_ARG_KEYWORDS_SPACE_SEP , REPEATABLE_KEYWORDS } ;
12-
13- #[ derive( Debug , Clone , Copy , PartialEq ) ]
14- enum KeywordType {
15- CommaSeparated ,
16- SpaceSeparated ,
17- Unseparated
18- }
11+ use crate :: metadata:: { MULTI_ARG_KEYWORDS , REPEATABLE_KEYWORDS } ;
1912
2013#[ derive( Debug , JsonSchema ) ]
2114pub struct SshdConfigParser {
@@ -187,7 +180,6 @@ impl SshdConfigParser {
187180 let mut operator: Option < String > = None ;
188181 let mut is_vec = false ;
189182 let mut is_repeatable = false ;
190- let mut keyword_type = KeywordType :: Unseparated ;
191183
192184 if let Some ( keyword) = keyword_node. child_by_field_name ( "keyword" ) {
193185 let Ok ( text) = keyword. utf8_text ( input_bytes) else {
@@ -198,13 +190,8 @@ impl SshdConfigParser {
198190 debug ! ( "{}" , t!( "parser.keywordDebug" , text = text) . to_string( ) ) ;
199191 }
200192
201- if MULTI_ARG_KEYWORDS_SPACE_SEP . contains ( & text) {
202- keyword_type = KeywordType :: SpaceSeparated ;
203- } else if MULTI_ARG_KEYWORDS_COMMA_SEP . contains ( & text) {
204- keyword_type = KeywordType :: CommaSeparated ;
205- }
206193 is_repeatable = REPEATABLE_KEYWORDS . contains ( & text) ;
207- is_vec = is_repeatable || keyword_type != KeywordType :: Unseparated ;
194+ is_vec = is_repeatable || MULTI_ARG_KEYWORDS . contains ( & text ) ;
208195 key = Some ( text. to_string ( ) ) ;
209196 }
210197
@@ -221,7 +208,7 @@ impl SshdConfigParser {
221208 return Err ( SshdConfigError :: ParserError ( t ! ( "parser.failedToParseNode" , input = input) . to_string ( ) ) ) ;
222209 }
223210 if node. kind ( ) == "arguments" {
224- value = parse_arguments_node ( node, input, input_bytes, is_vec, keyword_type ) ?;
211+ value = parse_arguments_node ( node, input, input_bytes, is_vec) ?;
225212 if target_map. is_some ( ) {
226213 debug ! ( "{}: {:?}" , t!( "parser.valueDebug" ) . to_string( ) , value) ;
227214 }
@@ -290,7 +277,7 @@ impl SshdConfigParser {
290277 }
291278}
292279
293- fn parse_arguments_node ( arg_node : tree_sitter:: Node , input : & str , input_bytes : & [ u8 ] , is_vec : bool , _keyword_type : KeywordType ) -> Result < Value , SshdConfigError > {
280+ fn parse_arguments_node ( arg_node : tree_sitter:: Node , input : & str , input_bytes : & [ u8 ] , is_vec : bool ) -> Result < Value , SshdConfigError > {
294281 let mut cursor = arg_node. walk ( ) ;
295282 let mut vec: Vec < Value > = Vec :: new ( ) ;
296283 // if there is more than one argument, but a vector is not expected for the keyword, throw an error
@@ -323,7 +310,7 @@ fn parse_arguments_node(arg_node: tree_sitter::Node, input: &str, input_bytes: &
323310 _ => return Err ( SshdConfigError :: ParserError ( t ! ( "parser.unknownNode" , kind = node. kind( ) ) . to_string ( ) ) )
324311 }
325312 }
326- // Always return array if is_vec is true (for MULTI_ARG_KEYWORDS_COMMA_SEP, MULTI_ARG_KEYWORDS_SPACE_SEP , and REPEATABLE_KEYWORDS)
313+ // Always return array if is_vec is true (for MULTI_ARG_KEYWORDS , and REPEATABLE_KEYWORDS)
327314 if is_vec {
328315 Ok ( Value :: Array ( vec) )
329316 } else if !vec. is_empty ( ) {
0 commit comments