@@ -9,9 +9,7 @@ use crate::io::{file_util, submission_processing, tmc_zip};
99use crate :: policy:: StudentFilePolicy ;
1010pub use isolang:: Language ;
1111use log:: debug;
12- use nom:: { bytes:: complete, combinator, error:: ErrorKind , error:: ParseError , sequence, IResult } ;
13- use once_cell:: sync:: Lazy ;
14- use regex:: Regex ;
12+ use nom:: { branch, bytes, character, combinator, multi, sequence, IResult } ;
1513use std:: collections:: { HashMap , HashSet } ;
1614use std:: io:: { Read , Seek , Write } ;
1715use std:: path:: { Path , PathBuf } ;
@@ -448,39 +446,35 @@ pub trait LanguagePlugin {
448446 log:: debug!( "parsing points from {}" , entry. path( ) . display( ) ) ;
449447 let file_contents = file_util:: read_file_to_string ( entry. path ( ) ) ?;
450448
451- let etc_parser = nom :: combinator:: value ( Parse :: Other , complete:: take ( 1usize ) ) ;
452- let line_comment_parser = nom :: combinator:: value (
449+ let etc_parser = combinator:: value ( Parse :: Other , bytes :: complete:: take ( 1usize ) ) ;
450+ let line_comment_parser = combinator:: value (
453451 Parse :: LineComment ,
454- nom :: sequence:: pair (
455- nom :: bytes:: complete:: tag ( Self :: LINE_COMMENT ) ,
456- nom :: bytes:: complete:: is_not ( "\n " ) ,
452+ sequence:: pair (
453+ bytes:: complete:: tag ( Self :: LINE_COMMENT ) ,
454+ bytes:: complete:: is_not ( "\n " ) ,
457455 ) ,
458456 ) ;
459457 let block_comment_parser: Box < dyn Fn ( _) -> _ > =
460458 if let Some ( block_comment) = Self :: BLOCK_COMMENT {
461- Box :: new ( nom :: combinator:: value (
459+ Box :: new ( combinator:: value (
462460 Parse :: BlockComment ,
463- nom :: sequence:: pair (
464- nom :: bytes:: complete:: tag ( block_comment. 0 ) ,
465- nom :: bytes:: complete:: is_not ( block_comment. 1 ) ,
461+ sequence:: pair (
462+ bytes:: complete:: tag ( block_comment. 0 ) ,
463+ bytes:: complete:: is_not ( block_comment. 1 ) ,
466464 ) ,
467465 ) )
468466 } else {
469- Box :: new ( nom :: combinator:: value (
467+ Box :: new ( combinator:: value (
470468 Parse :: Other ,
471- complete:: take_while ( |_| false ) ,
469+ bytes :: complete:: take_while ( |_| false ) ,
472470 ) )
473471 } ;
474472 let points_parser =
475- nom :: combinator:: map ( Self :: points_parser, |p| Parse :: Points ( p. to_string ( ) ) ) ;
473+ combinator:: map ( Self :: points_parser, |p| Parse :: Points ( p. to_string ( ) ) ) ;
476474
477- let parser = nom :: multi:: many0 ( nom :: multi:: many_till (
475+ let parser = multi:: many0 ( multi:: many_till (
478476 etc_parser,
479- nom:: branch:: alt ( (
480- line_comment_parser,
481- block_comment_parser,
482- points_parser,
483- ) ) ,
477+ branch:: alt ( ( line_comment_parser, block_comment_parser, points_parser) ) ,
484478 ) ) ;
485479 let res: IResult < _ , _ > = parser ( & file_contents) ;
486480 let ( _, parsed) = res. unwrap ( ) ;
@@ -502,10 +496,10 @@ pub trait LanguagePlugin {
502496}
503497
504498pub fn simple_delimited < ' a > ( limiter : char ) -> impl Fn ( & ' a str ) -> IResult < & ' a str , & ' a str > {
505- nom :: sequence:: delimited (
506- nom :: character:: complete:: char ( limiter) ,
507- nom :: bytes:: complete:: take_till ( move |c| c == limiter) ,
508- nom :: character:: complete:: char ( limiter) ,
499+ sequence:: delimited (
500+ character:: complete:: char ( limiter) ,
501+ bytes:: complete:: take_till ( move |c| c == limiter) ,
502+ character:: complete:: char ( limiter) ,
509503 )
510504}
511505
@@ -579,31 +573,31 @@ mod test {
579573 }
580574
581575 fn points_parser < ' a > ( i : & ' a str ) -> IResult < & ' a str , & ' a str > {
582- nom :: combinator:: map (
583- nom :: sequence:: delimited (
584- nom :: sequence:: tuple ( (
585- nom :: bytes:: complete:: tag ( "@" ) ,
586- nom :: character:: complete:: multispace0,
587- nom :: bytes:: complete:: tag_no_case ( "points" ) ,
588- nom :: character:: complete:: multispace0,
589- nom :: character:: complete:: char ( '(' ) ,
590- nom :: character:: complete:: multispace0,
576+ combinator:: map (
577+ sequence:: delimited (
578+ sequence:: tuple ( (
579+ bytes:: complete:: tag ( "@" ) ,
580+ character:: complete:: multispace0,
581+ bytes:: complete:: tag_no_case ( "points" ) ,
582+ character:: complete:: multispace0,
583+ character:: complete:: char ( '(' ) ,
584+ character:: complete:: multispace0,
591585 ) ) ,
592- nom :: branch:: alt ( (
593- nom :: sequence:: delimited (
594- nom :: character:: complete:: char ( '"' ) ,
595- nom :: bytes:: complete:: is_not ( "\" " ) ,
596- nom :: character:: complete:: char ( '"' ) ,
586+ branch:: alt ( (
587+ sequence:: delimited (
588+ character:: complete:: char ( '"' ) ,
589+ bytes:: complete:: is_not ( "\" " ) ,
590+ character:: complete:: char ( '"' ) ,
597591 ) ,
598- nom :: sequence:: delimited (
599- nom :: character:: complete:: char ( '\'' ) ,
600- nom :: bytes:: complete:: is_not ( "'" ) ,
601- nom :: character:: complete:: char ( '\'' ) ,
592+ sequence:: delimited (
593+ character:: complete:: char ( '\'' ) ,
594+ bytes:: complete:: is_not ( "'" ) ,
595+ character:: complete:: char ( '\'' ) ,
602596 ) ,
603597 ) ) ,
604- nom :: sequence:: tuple ( (
605- nom :: character:: complete:: multispace0,
606- nom :: character:: complete:: char ( ')' ) ,
598+ sequence:: tuple ( (
599+ character:: complete:: multispace0,
600+ character:: complete:: char ( ')' ) ,
607601 ) ) ,
608602 ) ,
609603 str:: trim,
0 commit comments