@@ -13,13 +13,14 @@ use std::io::BufReader;
13
13
use std:: path:: { Path , PathBuf } ;
14
14
use std:: time:: Duration ;
15
15
use tmc_langs_framework:: {
16
- nom:: { branch , bytes, character, combinator, error:: VerboseError , sequence, IResult } ,
16
+ nom:: { bytes, character, combinator, error:: VerboseError , sequence, IResult } ,
17
17
CommandError , ExerciseDesc , LanguagePlugin , Output , RunResult , RunStatus , TestDesc , TestResult ,
18
18
TmcCommand , TmcError , TmcProjectYml ,
19
19
} ;
20
20
use tmc_langs_util:: {
21
21
file_util,
22
22
notification_reporter:: { self , Notification } ,
23
+ parse_util,
23
24
} ;
24
25
use walkdir:: WalkDir ;
25
26
@@ -382,33 +383,28 @@ impl LanguagePlugin for Python3Plugin {
382
383
combinator:: map (
383
384
sequence:: delimited (
384
385
sequence:: tuple ( (
385
- bytes :: complete:: tag ( "@" ) ,
386
+ character :: complete:: char ( '@' ) ,
386
387
character:: complete:: multispace0,
387
388
bytes:: complete:: tag_no_case ( "points" ) ,
388
389
character:: complete:: multispace0,
389
390
character:: complete:: char ( '(' ) ,
390
391
character:: complete:: multispace0,
391
392
) ) ,
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,
404
394
sequence:: tuple ( (
405
395
character:: complete:: multispace0,
406
396
character:: complete:: char ( ')' ) ,
407
397
) ) ,
408
398
) ,
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
+ } ,
410
407
) ( i)
411
- . map ( |( a, b) | ( a, vec ! [ b] ) )
412
408
}
413
409
}
414
410
@@ -723,18 +719,24 @@ class TestErroring(unittest.TestCase):
723
719
#[ test]
724
720
fn parses_points ( ) {
725
721
assert_eq ! (
726
- Python3Plugin :: points_parser( "@points('p1')" ) . unwrap( ) . 1 [ 0 ] ,
727
- "p1"
722
+ Python3Plugin :: points_parser( "@points('p1')" ) . unwrap( ) . 1 ,
723
+ & [ "p1" ]
728
724
) ;
729
725
assert_eq ! (
730
726
Python3Plugin :: points_parser( "@ pOiNtS ( ' p2 ' ) " )
731
727
. 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" ]
734
734
) ;
735
735
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" ]
738
740
) ;
739
741
assert ! ( Python3Plugin :: points_parser( r#"@points("p3')"# ) . is_err( ) ) ;
740
742
}
0 commit comments