Skip to content

Commit

Permalink
Renamed StringLiteral to MemoryLiteral to avoid public API conflict w…
Browse files Browse the repository at this point in the history
…ith the same name. Added parsers for the various Rangers. Removed lambda based Checkers; will be specialized nodes going forward. I have a different approach in mind for what lambda checkers originally did.
  • Loading branch information
Entomy committed May 28, 2021
1 parent 109c981 commit 5798e39
Show file tree
Hide file tree
Showing 32 changed files with 1,214 additions and 271 deletions.
330 changes: 330 additions & 0 deletions Documentation/log.txt

Large diffs are not rendered by default.

57 changes: 0 additions & 57 deletions Stringier.Patterns/AlternateCharChecker.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Stringier.Patterns/Alternator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override Pattern Many() {

/// <inheritdoc/>
[return: NotNull]
public override Pattern Or([AllowNull] String other) => other is not null ? new ChainAlternator(Left, Right, new StringLiteral(other)) : this;
public override Pattern Or([AllowNull] String other) => other is not null ? new ChainAlternator(Left, Right, new MemoryLiteral(other)) : this;
/// <inheritdoc/>
protected internal override void Consume(ReadOnlyMemory<Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd<Capture> trace) {
Left.Consume(source, ref location, out exception, trace);
Expand Down
16 changes: 16 additions & 0 deletions Stringier.Patterns/Bias.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Stringier.Patterns {
/// <summary>
/// Word letter bias, used by <see cref="WordChecker"/>.
/// </summary>
public enum Bias {
/// <summary>
/// Bias towards the head
/// </summary>
Head,

/// <summary>
/// Bias towards the tail
/// </summary>
Tail,
}
}
2 changes: 1 addition & 1 deletion Stringier.Patterns/ChainAlternator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public override Pattern Or([AllowNull] Pattern other) {

/// <inheritdoc/>
[return: NotNull]
public override Pattern Or([AllowNull] String other) => other is not null ? new ChainAlternator(Patterns, new StringLiteral(other)) : this;
public override Pattern Or([AllowNull] String other) => other is not null ? new ChainAlternator(Patterns, new MemoryLiteral(other)) : this;
/// <inheritdoc/>
protected internal override void Consume(ReadOnlyMemory<Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd<Capture> trace) {
exception = null;
Expand Down
8 changes: 4 additions & 4 deletions Stringier.Patterns/ChainEnumAlternator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal sealed class ChainEnumAlternator<TEnum> : Combinator where TEnum : stru
protected internal override void Consume(ReadOnlyMemory<Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd<Capture> trace) {
exception = null;
foreach (String name in FastEnum.GetNames<TEnum>()) {
new StringLiteral(name).Consume(source, ref location, out exception, trace);
new MemoryLiteral(name).Consume(source, ref location, out exception, trace);
if (exception is null) return;
}
}
Expand All @@ -38,7 +38,7 @@ protected internal override void Consume(ReadOnlyMemory<Char> source, ref Int32
protected internal override unsafe void Consume([DisallowNull] Char* source, Int32 length, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd<Capture> trace) {
exception = null;
foreach (String name in FastEnum.GetNames<TEnum>()) {
new StringLiteral(name).Consume(source, length, ref location, out exception, trace);
new MemoryLiteral(name).Consume(source, length, ref location, out exception, trace);
if (exception is null) return;
}
}
Expand All @@ -65,7 +65,7 @@ protected internal override void Neglect(ReadOnlyMemory<Char> source, ref Int32
Int32 start = location;
Int32 shortest = Int32.MaxValue;
foreach (String name in FastEnum.GetNames<TEnum>().Reverse()) {
new StringLiteral(name).Neglect(source, ref location, out exception, trace);
new MemoryLiteral(name).Neglect(source, ref location, out exception, trace);
if (location - start < shortest) {
shortest = location - start;
}
Expand All @@ -84,7 +84,7 @@ protected internal override unsafe void Neglect([DisallowNull] Char* source, Int
Int32 start = location;
Int32 shortest = Int32.MaxValue;
foreach (String name in FastEnum.GetNames<TEnum>().Reverse()) {
new StringLiteral(name).Neglect(source, length, ref location, out exception, trace);
new MemoryLiteral(name).Neglect(source, length, ref location, out exception, trace);
if (location - start < shortest) {
shortest = location - start;
}
Expand Down
59 changes: 0 additions & 59 deletions Stringier.Patterns/CharChecker.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Stringier.Patterns/CharLiteral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal CharLiteral(Char @char) : this(@char, default) { }

/// <inheritdoc/>
[return: NotNull]
public override Pattern Repeat(Int32 count) => new StringLiteral(new String(Char, count), Casing);
public override Pattern Repeat(Int32 count) => new MemoryLiteral(new String(Char, count), Casing);

/// <inheritdoc/>
[return: NotNull]
Expand Down
Loading

0 comments on commit 5798e39

Please sign in to comment.