@@ -88,11 +88,11 @@ private void Process(string text)
8888 index = match . Index + match . Length ;
8989
9090 // All tokens except magic comment are inert
91- if ( match . Value [ 0 ] != '-' )
91+ if ( text [ match . Index ] is not '-' )
9292 continue ;
9393
94- // Recognized a magic comment
95- start = HandleMagicComment ( text , start , index , match ) ;
94+ // Recognized a potentially magic comment
95+ start = HandleComment ( text , start , index , match ) ;
9696 }
9797 }
9898
@@ -103,10 +103,13 @@ public ImmutableArray<SeedModule> Complete()
103103 return _modules . ToImmutable ( ) ;
104104 }
105105
106- private int HandleMagicComment ( string text , int start , int index , Match match )
106+ private int HandleComment ( string text , int start , int index , Match match )
107107 {
108108 // Decode
109- var command = match . Groups [ "cmd" ] ;
109+ var command = match . Groups [ "cmd" ] ;
110+ if ( ! command . Success )
111+ return start ; // skip non-magic comment
112+
110113 var arguments = match . Groups [ "arg" ] . Captures ;
111114
112115 // Dispatch
@@ -233,7 +236,8 @@ _batches .ToImmutable(),
233236 ^--\# [ \t]* (?<cmd> MODULE | PROVIDES | REQUIRES | WORKER) : # magic comment
234237 [ \t]* ( # followed by
235238 (?<arg> ( [^ \t\r\n] | \r(?!\n) )+ ) [ \t]* # arguments
236- )* ( \r?\n | \z )
239+ )* ( \r?\n | \z ) | #
240+ -- ( [^\r\n] | \r(?!\n) )* ( \r?\n | \z ) # line comment
237241 """ ,
238242 IgnoreCase |
239243 IgnorePatternWhitespace |
0 commit comments