@@ -13,13 +13,14 @@ use std::io::BufReader;
1313use std:: path:: { Path , PathBuf } ;
1414use std:: time:: Duration ;
1515use tmc_langs_framework:: {
16- nom:: { branch , bytes, character, combinator, error:: VerboseError , sequence, IResult } ,
16+ nom:: { bytes, character, combinator, error:: VerboseError , sequence, IResult } ,
1717 CommandError , ExerciseDesc , LanguagePlugin , Output , RunResult , RunStatus , TestDesc , TestResult ,
1818 TmcCommand , TmcError , TmcProjectYml ,
1919} ;
2020use tmc_langs_util:: {
2121 file_util,
2222 notification_reporter:: { self , Notification } ,
23+ parse_util,
2324} ;
2425use walkdir:: WalkDir ;
2526
@@ -382,33 +383,28 @@ impl LanguagePlugin for Python3Plugin {
382383 combinator:: map (
383384 sequence:: delimited (
384385 sequence:: tuple ( (
385- bytes :: complete:: tag ( "@" ) ,
386+ character :: complete:: char ( '@' ) ,
386387 character:: complete:: multispace0,
387388 bytes:: complete:: tag_no_case ( "points" ) ,
388389 character:: complete:: multispace0,
389390 character:: complete:: char ( '(' ) ,
390391 character:: complete:: multispace0,
391392 ) ) ,
392- branch:: alt ( (
393- sequence:: delimited (
394- character:: complete:: char ( '"' ) ,
395- bytes:: complete:: is_not ( "\" " ) ,
396- character:: complete:: char ( '"' ) ,
397- ) ,
398- sequence:: delimited (
399- character:: complete:: char ( '\'' ) ,
400- bytes:: complete:: is_not ( "'" ) ,
401- character:: complete:: char ( '\'' ) ,
402- ) ,
403- ) ) ,
393+ parse_util:: comma_separated_strings_either,
404394 sequence:: tuple ( (
405395 character:: complete:: multispace0,
406396 character:: complete:: char ( ')' ) ,
407397 ) ) ,
408398 ) ,
409- str:: trim,
399+ // splits each point by whitespace
400+ |points| {
401+ points
402+ . into_iter ( )
403+ . map ( |p| p. split_whitespace ( ) )
404+ . flatten ( )
405+ . collect ( )
406+ } ,
410407 ) ( i)
411- . map ( |( a, b) | ( a, vec ! [ b] ) )
412408 }
413409}
414410
@@ -723,18 +719,24 @@ class TestErroring(unittest.TestCase):
723719 #[ test]
724720 fn parses_points ( ) {
725721 assert_eq ! (
726- Python3Plugin :: points_parser( "@points('p1')" ) . unwrap( ) . 1 [ 0 ] ,
727- "p1"
722+ Python3Plugin :: points_parser( "@points('p1')" ) . unwrap( ) . 1 ,
723+ & [ "p1" ]
728724 ) ;
729725 assert_eq ! (
730726 Python3Plugin :: points_parser( "@ pOiNtS ( ' p2 ' ) " )
731727 . unwrap( )
732- . 1 [ 0 ] ,
733- "p2"
728+ . 1 ,
729+ & [ "p2" ]
730+ ) ;
731+ assert_eq ! (
732+ Python3Plugin :: points_parser( r#"@points("p3")"# ) . unwrap( ) . 1 ,
733+ & [ "p3" ]
734734 ) ;
735735 assert_eq ! (
736- Python3Plugin :: points_parser( r#"@points("p3")"# ) . unwrap( ) . 1 [ 0 ] ,
737- "p3"
736+ Python3Plugin :: points_parser( r#"@points("p3", 'p4', "p5", "p6 p7")"# )
737+ . unwrap( )
738+ . 1 ,
739+ & [ "p3" , "p4" , "p5" , "p6" , "p7" ]
738740 ) ;
739741 assert ! ( Python3Plugin :: points_parser( r#"@points("p3')"# ) . is_err( ) ) ;
740742 }
0 commit comments