Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intermediate commit for major atomic stage refactoring
- Loading branch information
Showing
28 changed files
with
925 additions
and
370 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
|
||
namespace Retina.Configuration | ||
{ | ||
public class Config | ||
{ | ||
public RegexOptions RegexOptions { get; set; } | ||
|
||
// General configuration | ||
public List<Limit> Limits { get; set; } | ||
|
||
// This is only relevant for stages with multiple patterns. | ||
// If this is true, the patterns will be chosen from greedily. | ||
// If this is false, the patterns will be cycled through instead. | ||
public bool Greedy { get; set; } | ||
|
||
// If this is true, the stage's input will be used as the regex, and the first | ||
// line of the stage will be used as the input. | ||
public bool InputAsRegex { get; set; } | ||
|
||
// If this is true, the matches and the separators between them | ||
// will swap their roles. | ||
public bool InvertMatches { get; set; } | ||
|
||
// Custom regex modifiers | ||
|
||
// How to treat overlapping matches. | ||
public Overlaps Overlaps { get; set; } | ||
// How to treat repeated matches. | ||
public UniqueMatches UniqueMatches { get; set; } | ||
// Require the regex to cover the entire input. | ||
public bool Anchored { get; set; } | ||
|
||
// General options which are interpreted differently by various stage types. | ||
public bool Reverse { get; set; } | ||
public bool Random { get; set; } | ||
public string ListStart { get; set; } | ||
public string ListSeparator { get; set; } | ||
public string ListEnd { get; set; } | ||
|
||
// Configuration for Output stages | ||
public bool TrailingLinefeed { get; set; } | ||
public bool PrintOnlyIfChanged { get; set; } | ||
|
||
// Configuration for Split mode | ||
public bool OmitEmpty { get; set; } | ||
public bool OmitGroups { get; set; } | ||
|
||
public Config() | ||
{ | ||
Limits = new List<Limit>(); | ||
ListStart = ""; | ||
ListEnd = ""; | ||
ListSeparator = "\n"; | ||
} | ||
|
||
public void Inherit(Config other) | ||
{ | ||
RegexOptions ^= other.RegexOptions; | ||
} | ||
|
||
public void Merge(Config other) | ||
{ | ||
RegexOptions ^= other.RegexOptions; | ||
Limits.AddRange(other.Limits); | ||
} | ||
|
||
public Limit GetLimit(int i) | ||
{ | ||
return i < Limits.Count ? Limits[i] : new Limit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 21 additions & 20 deletions
41
Retina/Retina/Modes.cs → Retina/Retina/Configuration/Modes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Retina | ||
{ | ||
public enum Modes | ||
{ | ||
Match, | ||
Grep, | ||
AntiGrep, | ||
Split, | ||
Replace, | ||
Transliterate, | ||
Sort, | ||
Deduplicate | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Retina.Configuration | ||
{ | ||
public enum Modes | ||
{ | ||
Count, | ||
Match, | ||
Grep, | ||
AntiGrep, | ||
Split, | ||
Replace, | ||
Transliterate, | ||
Sort, | ||
Deduplicate | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Retina.Configuration | ||
{ | ||
public enum Overlaps | ||
{ | ||
None = 0, | ||
// Find up to one match per starting-position, even if they overlap. | ||
OverlappingSimple, | ||
// Find all substrings that can be matched, even if they overlap. | ||
OverlappingAll, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Retina.Configuration | ||
{ | ||
public enum UniqueMatches | ||
{ | ||
Off = 0, | ||
// If the same substring is matched multiple times, discard the new one. | ||
KeepFirst, | ||
// If the same substring is matched multiple times, discard the old one. | ||
KeepLast, | ||
} | ||
} |
Oops, something went wrong.