1
1
using Rubberduck . RegexAssistant . Extensions ;
2
2
using Rubberduck . RegexAssistant . i18n ;
3
- using System ;
4
3
using System . Collections . Generic ;
5
4
using System . Linq ;
6
5
using System . Text . RegularExpressions ;
@@ -29,7 +28,6 @@ public string Description
29
28
get
30
29
{
31
30
return AssistantResources . ExpressionDescription_ConcatenatedExpression ;
32
- //return string.Join(Environment.NewLine, _subexpressions.Select(exp => exp.Description));
33
31
}
34
32
}
35
33
@@ -66,7 +64,6 @@ public string Description
66
64
get
67
65
{
68
66
return AssistantResources . ExpressionDescription_AlternativesExpression ;
69
- // + Environment.NewLine + string.Join(Environment.NewLine, _subexpressions.Select(exp => exp.Description))
70
67
}
71
68
}
72
69
@@ -229,7 +226,6 @@ private static IRegularExpression ParseIntoConcatenatedExpression(ref string spe
229
226
int oldSpecifierLength = currentSpecifier . Length + 1 ;
230
227
while ( currentSpecifier . Length > 0 && currentSpecifier . Length < oldSpecifierLength )
231
228
{
232
- // Fugly hack for an error-return
233
229
oldSpecifierLength = currentSpecifier . Length ;
234
230
IRegularExpression expression ;
235
231
// we actually have an AlternativesExpression, return the current status to Parse after updating the specifier
@@ -300,77 +296,5 @@ internal static bool TryParseAsAtom(ref string specifier, out IRegularExpression
300
296
expression = null ;
301
297
return false ;
302
298
}
303
-
304
- /// <summary>
305
- /// Makes the given specifier with the given pipeIndices into an AlternativesExpression
306
- /// </summary>
307
- /// <param name="pipeIndices">The indices of Alternative-indicating pipes on the current expression level</param>
308
- /// <param name="specifier">The specifier to split into subexpressions</param>
309
- /// <returns>An AlternativesExpression consisting of the split alternatives in the specifier, in order of encounter</returns>
310
- private static IRegularExpression ParseIntoAlternativesExpression ( List < int > pipeIndices , string specifier )
311
- {
312
- List < IRegularExpression > expressions = new List < IRegularExpression > ( ) ;
313
- string currentRemainder = specifier ;
314
- for ( int i = pipeIndices . Count - 1 ; i > 0 ; i -- )
315
- {
316
- expressions . Add ( Parse ( currentRemainder . Substring ( pipeIndices [ i ] + 1 ) ) ) ;
317
- currentRemainder = currentRemainder . Substring ( 0 , pipeIndices [ i ] - 1 ) ;
318
- }
319
- expressions . Reverse ( ) ; // because we built them from the back
320
- return new AlternativesExpression ( expressions ) ;
321
- }
322
-
323
-
324
- /// <summary>
325
- /// Finds all Pipes in the given specifier that are not escaped
326
- /// </summary>
327
- /// <param name="specifier">the regex specifier to search for unescaped pipes</param>
328
- /// <returns>A list populated with the indices of all pipes</returns>
329
- private static List < int > GrabPipeIndices ( string specifier )
330
- {
331
- // FIXME: Check assumptions:
332
- // - | is never encountered at index 0
333
- // - | is never preceded by \\
334
-
335
- if ( ! specifier . Contains ( "|" ) ) {
336
- return new List < int > ( ) ;
337
- }
338
- int currentIndex = 0 ;
339
- List < int > result = new List < int > ( ) ;
340
- while ( true )
341
- {
342
- currentIndex = specifier . IndexOf ( "|" , currentIndex ) ;
343
- if ( currentIndex == - 1 )
344
- {
345
- break ;
346
- }
347
- // ignore escaped literals
348
- // FIXME this is still a little too naive, since we could actually have something like "\\\|", which means that | is escaped again, but it should suffice for now
349
- if ( currentIndex == 0 || ! specifier . Substring ( currentIndex - 1 , 2 ) . Equals ( "\\ |" )
350
- || ( currentIndex > 1 && specifier . Substring ( currentIndex - 2 , 2 ) . Equals ( "\\ \\ " ) ) )
351
- {
352
- result . Add ( currentIndex ) ;
353
- }
354
- }
355
- return result ;
356
- }
357
-
358
- /// <summary>
359
- /// Weeds out pipe indices that do not signify alternatives at the current "top level" from the given String.
360
- /// </summary>
361
- /// <param name="pipeIndices">indices of unescaped pipes in the given specifier</param>
362
- /// <param name="specifier">the regex specifier under scrutiny</param>
363
- internal static void WeedPipeIndices ( ref List < int > pipeIndices , string specifier )
364
- {
365
- if ( pipeIndices . Count == 0 )
366
- {
367
- return ;
368
- }
369
- foreach ( int pipeIndex in pipeIndices )
370
- {
371
- // must not be between () or [] braces, else we just weed it out
372
-
373
- }
374
- }
375
299
}
376
300
}
0 commit comments