@@ -373,27 +373,7 @@ impl<'run, 'src> Parser<'run, 'src> {
373
373
|| self . next_are ( & [ Identifier , QuestionMark ] ) =>
374
374
{
375
375
let doc = pop_doc_comment ( & mut items, eol_since_last_comment) ;
376
-
377
- self . presume_keyword ( Keyword :: Mod ) ?;
378
-
379
- let optional = self . accepted ( QuestionMark ) ?;
380
-
381
- let name = self . parse_name ( ) ?;
382
-
383
- let relative = if self . next_is ( StringToken ) || self . next_are ( & [ Identifier , StringToken ] )
384
- {
385
- Some ( self . parse_string_literal ( ) ?)
386
- } else {
387
- None
388
- } ;
389
-
390
- items. push ( Item :: Module {
391
- absolute : None ,
392
- doc,
393
- name,
394
- optional,
395
- relative,
396
- } ) ;
376
+ items. push ( self . parse_module ( BTreeSet :: new ( ) , doc) ?) ;
397
377
}
398
378
Some ( Keyword :: Set )
399
379
if self . next_are ( & [ Identifier , Identifier , ColonEquals ] )
@@ -430,6 +410,17 @@ impl<'run, 'src> Parser<'run, 'src> {
430
410
Some ( Keyword :: Alias ) if self . next_are ( & [ Identifier , Identifier , ColonEquals ] ) => {
431
411
items. push ( Item :: Alias ( self . parse_alias ( attributes) ?) ) ;
432
412
}
413
+ Some ( Keyword :: Mod )
414
+ if self . next_are ( & [ Identifier , Identifier , Comment ] )
415
+ || self . next_are ( & [ Identifier , Identifier , Eof ] )
416
+ || self . next_are ( & [ Identifier , Identifier , Eol ] )
417
+ || self . next_are ( & [ Identifier , Identifier , Identifier , StringToken ] )
418
+ || self . next_are ( & [ Identifier , Identifier , StringToken ] )
419
+ || self . next_are ( & [ Identifier , QuestionMark ] ) =>
420
+ {
421
+ let doc = pop_doc_comment ( & mut items, eol_since_last_comment) ;
422
+ items. push ( self . parse_module ( attributes, doc) ?) ;
423
+ }
433
424
_ => {
434
425
let quiet = self . accepted ( At ) ?;
435
426
let doc = pop_doc_comment ( & mut items, eol_since_last_comment) ;
@@ -454,6 +445,33 @@ impl<'run, 'src> Parser<'run, 'src> {
454
445
}
455
446
}
456
447
448
+ fn parse_module (
449
+ & mut self ,
450
+ attributes : BTreeSet < Attribute < ' src > > ,
451
+ doc : Option < & ' src str > ,
452
+ ) -> CompileResult < ' src , Item < ' src > > {
453
+ self . presume_keyword ( Keyword :: Mod ) ?;
454
+
455
+ let optional = self . accepted ( QuestionMark ) ?;
456
+
457
+ let name = self . parse_name ( ) ?;
458
+
459
+ let relative = if self . next_is ( StringToken ) || self . next_are ( & [ Identifier , StringToken ] ) {
460
+ Some ( self . parse_string_literal ( ) ?)
461
+ } else {
462
+ None
463
+ } ;
464
+
465
+ Ok ( Item :: Module {
466
+ attributes,
467
+ absolute : None ,
468
+ doc,
469
+ name,
470
+ optional,
471
+ relative,
472
+ } )
473
+ }
474
+
457
475
/// Parse an alias, e.g `alias name := target`
458
476
fn parse_alias (
459
477
& mut self ,
0 commit comments