Compare commits
22 Commits
414c74be84
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a630cac9a1 | ||
|
|
8475389b99 | ||
| 1d68b70fa5 | |||
| e41d93e301 | |||
| 19fdbe4dac | |||
| ec1e65c03b | |||
| f6701df12d | |||
| 610b628081 | |||
| f480334eee | |||
| 8608e4ddd1 | |||
| 7133ec1560 | |||
| 2f92f59a50 | |||
| 97a4da7531 | |||
| c577f15f91 | |||
| b4d55ddfc0 | |||
| f51aad91fa | |||
| cab7ac35ae | |||
| 86bb120e32 | |||
| c728509978 | |||
| 7bd2429a43 | |||
| d41d9f1791 | |||
| 1a8a82c106 |
@@ -57,12 +57,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
REPOSITORY_OWNER=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $1}')
|
REPOSITORY_OWNER=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $1}')
|
||||||
REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $2}' | tr '-' '_')
|
REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $2}' | tr '-' '_')
|
||||||
REPOSITORY_SOURCE_NAME=gitea-repo
|
|
||||||
if [ -z "$(dotnet nuget config get all | grep "/packages/${REPOSITORY_OWNER}/nuget/index.json")" ]; then
|
|
||||||
dotnet nuget add source --name $REPOSITORY_SOURCE_NAME https://git.disi.dev/api/packages/$REPOSITORY_OWNER/nuget/index.json
|
|
||||||
else
|
|
||||||
QUOTED_REPOSITORY_SOURCE_NAME=$(dotnet nuget config get all | grep "/packages/${REPOSITORY_OWNER}/nuget/index.json" | awk '{print $2}' | awk -F= '{print $2}')
|
|
||||||
REPOSITORY_SOURCE_NAME=${QUOTED_REPOSITORY_SOURCE_NAME:1:-1}
|
|
||||||
fi
|
|
||||||
dotnet pack --include-symbols --include-source -p:PackageVersion=$(cat $REPOSITORY_NAME/VERSION) TextParser.sln
|
dotnet pack --include-symbols --include-source -p:PackageVersion=$(cat $REPOSITORY_NAME/VERSION) TextParser.sln
|
||||||
dotnet nuget push -k $GITEA_PAT --source $REPOSITORY_SOURCE_NAME $REPOSITORY_NAME/bin/Release/$REPOSITORY_NAME.$(cat $REPOSITORY_NAME/VERSION).symbols.nupkg
|
echo "dotnet nuget push -k ${GITEA_PAT:0:-15} $REPOSITORY_NAME/bin/Release/$REPOSITORY_NAME.$(cat $REPOSITORY_NAME/VERSION).symbols.nupkg"
|
||||||
|
dotnet nuget push -k $GITEA_PAT $REPOSITORY_NAME/bin/Release/$REPOSITORY_NAME.$(cat $REPOSITORY_NAME/VERSION).symbols.nupkg
|
||||||
|
|||||||
181
HISTORY.md
181
HISTORY.md
@@ -1,181 +0,0 @@
|
|||||||
Changelog
|
|
||||||
=========
|
|
||||||
|
|
||||||
|
|
||||||
(unreleased)
|
|
||||||
------------
|
|
||||||
- Feat: add support for custom token types and longs, ref: NOISSUE.
|
|
||||||
[Simon Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.9.3 (2024-12-13)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Remove duplicate TokenConverter definition, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.9.2 (2024-12-13)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- More bugfixes, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.9.1 (2024-12-13)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Fix build issues, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.9.0 (2024-12-13)
|
|
||||||
------------------
|
|
||||||
- Feat: add filter option to TokenConverter, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.8.0 (2024-12-12)
|
|
||||||
------------------
|
|
||||||
- Feat: adding sensible index constructors refs: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.7.2 (2024-12-05)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Add some missing API methods, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.7.1 (2024-12-05)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Allow for parsing single chars as input, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.7.0 (2024-12-05)
|
|
||||||
------------------
|
|
||||||
- Feat: implement generic data set manipulator, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.6.0 (2024-12-03)
|
|
||||||
------------------
|
|
||||||
- Feat: enable named literals, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.5.1 (2024-12-03)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Some bugfixes with fragment parser logic, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.5.0 (2024-12-03)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Fix bugs with fragment parsing support, refs: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
- Feat: initial support for fragment parsing, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.4.0 (2024-12-02)
|
|
||||||
------------------
|
|
||||||
- Style: fix linting errors, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
- Feat: implement greedy repetition, ref: A24-13. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.3.0 (2024-12-02)
|
|
||||||
------------------
|
|
||||||
- Feat: ci pipeline fix for releases, ref NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.2.3 (2024-12-02)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- More release script fixes,ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.2.2 (2024-12-02)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Increment version,refs:NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
|
|
||||||
0.2.1 (2024-12-02)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Fix file inclusion in tag commits, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.2.0 (2024-12-02)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Fix
|
|
||||||
~~~
|
|
||||||
- Fix some bugs and tests, ref: A24-3. [Simon Diesenreiter]
|
|
||||||
|
|
||||||
Other
|
|
||||||
~~~~~
|
|
||||||
- Ci: fix release shortcut, ref: NOISSUE. [Simon Diesenreiter]
|
|
||||||
- Feat: add text parser and output format options, ref: A24-3. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
|
|
||||||
|
|
||||||
0.1.0 (2024-12-01)
|
|
||||||
------------------
|
|
||||||
- Feat: added initial implementation of TextParser, ref: A24-3. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
- ✅ Ready to clone and code. [simon]
|
|
||||||
- Ci: initial commit for triggering migration, ref: NOISSUE. [Simon
|
|
||||||
Diesenreiter]
|
|
||||||
- Initial commit. [Projects <>]
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class TextParserTests
|
|||||||
bca
|
bca
|
||||||
cab";
|
cab";
|
||||||
private const string testInput11 = @"2 x y 4 x y 6 x y 4 x y 1 x y";
|
private const string testInput11 = @"2 x y 4 x y 6 x y 4 x y 1 x y";
|
||||||
|
private const string testInput12 = @"abcd";
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void LineParser_TestSimpleRepetition()
|
public void LineParser_TestSimpleRepetition()
|
||||||
@@ -443,4 +444,27 @@ public class TextParserTests
|
|||||||
Assert.Equal(4, numbers[3]);
|
Assert.Equal(4, numbers[3]);
|
||||||
Assert.Equal(1, numbers[4]);
|
Assert.Equal(1, numbers[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TextParser_TestCharExplicit()
|
||||||
|
{
|
||||||
|
var schemaBuilder = new InputSchemaBuilder();
|
||||||
|
var schema = schemaBuilder
|
||||||
|
.Repeat()
|
||||||
|
.Expect(InputType.Char)
|
||||||
|
.EndRepetition()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var parser = new TextParser<InputSchemaContext>(schema);
|
||||||
|
var numbers = parser
|
||||||
|
.SetInputText(testInput12)
|
||||||
|
.Parse()
|
||||||
|
.AsSingleStream<string>();
|
||||||
|
|
||||||
|
Assert.Equal(4, numbers.Count);
|
||||||
|
Assert.Equal("a", numbers[0]);
|
||||||
|
Assert.Equal("b", numbers[1]);
|
||||||
|
Assert.Equal("c", numbers[2]);
|
||||||
|
Assert.Equal("d", numbers[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,32 +5,44 @@ using Parsing.Tokenization;
|
|||||||
|
|
||||||
public static class DataConversionHelpers
|
public static class DataConversionHelpers
|
||||||
{
|
{
|
||||||
public static List<TNewType> ConvertData<TNewType, TOldType>(this List<TOldType> valueList, Func<TOldType, TNewType> converter)
|
public static List<TNewType> ConvertData<TTokenType, TNewType, TOldType>(this List<IToken> tokenList, Func<TOldType, TNewType> converter) where TTokenType : IValueToken<TOldType>
|
||||||
{
|
{
|
||||||
var newList = new List<TNewType>();
|
var newList = new List<TNewType>();
|
||||||
foreach (var value in valueList)
|
foreach (var token in tokenList)
|
||||||
{
|
{
|
||||||
newList.Add(converter(value));
|
var typedToken = token as IValueToken<TOldType>;
|
||||||
|
if (typedToken == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Invalid Token type encountered during value conversion");
|
||||||
|
}
|
||||||
|
|
||||||
|
newList.Add(converter(typedToken.GetValue()));
|
||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TNewType> ConvertData<TNewType, TOldType>(this List<TOldType> valueList, Func<TOldType, List<TNewType>> converter)
|
public static List<TNewType> ConvertData<TTokenType, TNewType, TOldType>(this List<IToken> tokenList, Func<TOldType, List<TNewType>> converter) where TTokenType : IValueToken<TOldType>
|
||||||
{
|
{
|
||||||
var newList = new List<TNewType>();
|
var newList = new List<TNewType>();
|
||||||
foreach (var value in valueList)
|
foreach (var token in tokenList)
|
||||||
{
|
{
|
||||||
newList.AddRange(converter(value));
|
var typedToken = token as IValueToken<TOldType>;
|
||||||
|
if (typedToken == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Invalid Token type encountered during value conversion");
|
||||||
|
}
|
||||||
|
|
||||||
|
newList.AddRange(converter(typedToken.GetValue()));
|
||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<List<TNewType>> ConvertData<TNewType, TOldType>(this List<List<TOldType>> valueListList, Func<TOldType, TNewType> converter)
|
public static List<List<TNewType>> ConvertData<TTokenType, TNewType, TOldType>(this List<List<IToken>> tokenListList, Func<TOldType, TNewType> converter) where TTokenType : IValueToken<TOldType>
|
||||||
{
|
{
|
||||||
var newListList = new List<List<TNewType>>();
|
var newListList = new List<List<TNewType>>();
|
||||||
foreach (var valueList in valueListList)
|
foreach (var tokenList in tokenListList)
|
||||||
{
|
{
|
||||||
newListList.Add(valueList.ConvertData<TNewType, TOldType>(converter));
|
newListList.Add(tokenList.ConvertData<TTokenType, TNewType, TOldType>(converter));
|
||||||
}
|
}
|
||||||
return newListList;
|
return newListList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public static class DataManipulationHelpers
|
|||||||
return reducer(data);
|
return reducer(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TNewType> TransformData<TType, TNewType>(this IEnumerable<TType> data, Func<TType, TNewType> transformer)
|
public static List<TNewType> TransformData<TType, TNewType>(this List<TType> data, Func<TType, TNewType> transformer)
|
||||||
{
|
{
|
||||||
var newList = new List<TNewType>();
|
var newList = new List<TNewType>();
|
||||||
foreach (TType dataItem in data)
|
foreach (TType dataItem in data)
|
||||||
@@ -31,7 +31,7 @@ public static class DataManipulationHelpers
|
|||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TNewType> TransformData<TType, TNewType>(this IEnumerable<IEnumerable<TType>> data, Func<List<TType>, TNewType> transformer)
|
public static List<TNewType> TransformData<TType, TNewType>(this List<List<TType>> data, Func<List<TType>, TNewType> transformer)
|
||||||
{
|
{
|
||||||
var newList = new List<TNewType>();
|
var newList = new List<TNewType>();
|
||||||
foreach (List<TType> dataItemList in data)
|
foreach (List<TType> dataItemList in data)
|
||||||
@@ -40,21 +40,4 @@ public static class DataManipulationHelpers
|
|||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<List<TType>> IterateData<TType>(this List<List<TType>> data, Action<TType, int, int> iterator)
|
|
||||||
{
|
|
||||||
int y = data.Count;
|
|
||||||
foreach(var rowList in data)
|
|
||||||
{
|
|
||||||
y--;
|
|
||||||
int x = 0;
|
|
||||||
foreach(var item in rowList)
|
|
||||||
{
|
|
||||||
iterator(item, x, y);
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -98,8 +98,6 @@ public abstract class DataSetManipulatorBase<TCollectedType, TDataType, TIndexTy
|
|||||||
// we do not know how to iterate a specific data set exactly, but we only need to find specific items to be able to continue with any other algorithm
|
// we do not know how to iterate a specific data set exactly, but we only need to find specific items to be able to continue with any other algorithm
|
||||||
public abstract List<SearchResult<TIndexType>> FindInSet(TDataType data);
|
public abstract List<SearchResult<TIndexType>> FindInSet(TDataType data);
|
||||||
|
|
||||||
public abstract List<SearchResult<TIndexType>> GetAllItems();
|
|
||||||
|
|
||||||
public List<DirectionalSearchResult<TIndexType>> FindAtPosition(IDataIndex<TIndexType> currentPosition, List<TDataType> data)
|
public List<DirectionalSearchResult<TIndexType>> FindAtPosition(IDataIndex<TIndexType> currentPosition, List<TDataType> data)
|
||||||
{
|
{
|
||||||
return this.FindAtPosition(currentPosition, data, this.ValidDirections());
|
return this.FindAtPosition(currentPosition, data, this.ValidDirections());
|
||||||
|
|||||||
@@ -61,22 +61,6 @@ public class DefaultTwoDimensionalManipulator<TDataType> : DataSetManipulatorBas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<SearchResult<TIndexType>> GetAllItems()
|
|
||||||
{
|
|
||||||
var results = new List<SearchResult<int>>();
|
|
||||||
|
|
||||||
for (int y = 0; y < this.dataSet.Count; y++)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < this.dataSet[this.dataSet.Count - y - 1].Count; x++)
|
|
||||||
{
|
|
||||||
var singleResult = new SearchResult<int>(new DefaultPositionalDataIndex(x, y));
|
|
||||||
results.Add(singleResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<SearchResult<int>> FindInSet(TDataType data)
|
public override List<SearchResult<int>> FindInSet(TDataType data)
|
||||||
{
|
{
|
||||||
var results = new List<SearchResult<int>>();
|
var results = new List<SearchResult<int>>();
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ public class TokenConverter
|
|||||||
|
|
||||||
if (!token.GetType().IsAssignableTo(typeof(IValueToken<U>)))
|
if (!token.GetType().IsAssignableTo(typeof(IValueToken<U>)))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Token: " + token.GetText());
|
Console.WriteLine(token.GetText());
|
||||||
Type t = token.GetType();
|
Type t = token.GetType();
|
||||||
throw new Exception("Provided token is not a ValueToken - type: " + t.ToString() + " assigned to " + typeof(IValueToken<U>).ToString());
|
throw new Exception("Provided token is not a ValueToken - type: " + t.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
IValueToken<U> valueToken = token as IValueToken<U>;
|
IValueToken<U> valueToken = token as IValueToken<U>;
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
var manipulator = DefaultTwoDimensionalManipulator.Create(row);
|
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Parsing.Data;
|
|
||||||
|
|
||||||
namespace Parsing.Data;
|
|
||||||
|
|
||||||
public static class TwoDimensionalDataWalker
|
|
||||||
{
|
|
||||||
public static TwoDimensionalDataWalker<TDataType> Create<TDataType>(List<List<TDataType>> dataSet) where TDataType : IEquatable<TDataType>
|
|
||||||
{
|
|
||||||
return new TwoDimensionalDataWalker<TDataType>(dataSet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TwoDimensionalDataWalker<TDataType> where TDataType : IEquatable<TDataType>
|
|
||||||
{
|
|
||||||
private List<List<TDataType>> dataSet
|
|
||||||
|
|
||||||
private Func<TDataType, bool> startCondition;
|
|
||||||
private TDataType startValue;
|
|
||||||
private bool startValueSet = false;
|
|
||||||
private Func<List<TDataType>, TDataType, bool> walkCondition;
|
|
||||||
private Func<List<TDataType>, TDataType, bool> endCondition;
|
|
||||||
private Direction directions;
|
|
||||||
private DefaultTwoDimenstionalManipulator<TDataType> manipulator;
|
|
||||||
|
|
||||||
public TwoDimensionalDataWalker(List<List<TDataType>> dataSet)
|
|
||||||
{
|
|
||||||
this.dataSet = dataSet;
|
|
||||||
this.manipulator = DefaultTwoDimenstionalManipulator.Create(dataSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TwoDimensionalDataWalker<TDataType> WithStartCondition(Func<TDataType, bool> startCondition)
|
|
||||||
{
|
|
||||||
this.startCondition = startCondition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TwoDimensionalDataWalker<TDataType> WithStartValue(TDataType startValue)
|
|
||||||
{
|
|
||||||
this.startValue = startValue;
|
|
||||||
this.startValueSet = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TwoDimensionalDataWalker<TDataType> WithStepCondition(Func<List<TDataType>, TDataType, bool> stepCondition)
|
|
||||||
{
|
|
||||||
this.stepCondition = stepCondition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TwoDimensionalDataWalker<TDataType> WithEndCondition(Func<List<TDataType>, TDataType, bool> endCondition)
|
|
||||||
{
|
|
||||||
this.endCondition = endCondition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TwoDimensionalDataWalker<TDataType> WithDirections(Direction directions)
|
|
||||||
{
|
|
||||||
this.directions = directions;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<List<DirectionalSearchResult<int>>> WalkFromSingleStartPosition(SearchResult<int> start)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<List<DirectionalSearchResult<int>>> Walk()
|
|
||||||
{
|
|
||||||
List<SearchResult<int>> startingPoints;
|
|
||||||
|
|
||||||
if(this.startValueSet)
|
|
||||||
{
|
|
||||||
startingPoints = manipulator.FindInSet(this.startValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
startingPoints = manipulator.GetAllItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
var allFoundPaths = new List<List<DirectionalSearchResult<int>>>();
|
|
||||||
|
|
||||||
foreach(var startingPoint in startingPoints)
|
|
||||||
{
|
|
||||||
allFoundPaths.AddRange(this.WalkFromSingleStartPosition(startingPoint));
|
|
||||||
}
|
|
||||||
return allFoundPaths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -44,6 +44,6 @@ class CharBlock : BuildingBlockBase
|
|||||||
|
|
||||||
public override BlockType GetBlockType()
|
public override BlockType GetBlockType()
|
||||||
{
|
{
|
||||||
return BlockType.String;
|
return BlockType.Char;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,17 +28,17 @@ class StringBlock : BuildingBlockBase
|
|||||||
public override bool CanParseWord(string word)
|
public override bool CanParseWord(string word)
|
||||||
{
|
{
|
||||||
// Here we need to ensure we are not matching any non-string tokens, since string can match pretty much anything
|
// Here we need to ensure we are not matching any non-string tokens, since string can match pretty much anything
|
||||||
// LongBlock longBlock = new LongBlock();
|
LongBlock longBlock = new LongBlock();
|
||||||
// if (longBlock.CanParseWord(word))
|
if (longBlock.CanParseWord(word))
|
||||||
// {
|
{
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// IntegerBlock intBlock = new IntegerBlock();
|
IntegerBlock intBlock = new IntegerBlock();
|
||||||
// if (intBlock.CanParseWord(word))
|
if (intBlock.CanParseWord(word))
|
||||||
// {
|
{
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class FragmentSchema : ISchema<FragmentSchemaContext>
|
|||||||
private string fragmentRegex;
|
private string fragmentRegex;
|
||||||
private List<string> namedGroups = new List<string>();
|
private List<string> namedGroups = new List<string>();
|
||||||
private List<string> namedLiterals = new List<string>();
|
private List<string> namedLiterals = new List<string>();
|
||||||
|
private bool ignoreEmptyMatches = true;
|
||||||
|
|
||||||
public FragmentSchema(string fragmentRegex, List<string> namedGroups, List<string> namedLiterals)
|
public FragmentSchema(string fragmentRegex, List<string> namedGroups, List<string> namedLiterals)
|
||||||
{
|
{
|
||||||
@@ -33,6 +34,11 @@ public class FragmentSchema : ISchema<FragmentSchemaContext>
|
|||||||
// one token per match
|
// one token per match
|
||||||
foreach (Match match in r.Matches(inputs.YieldWord()))
|
foreach (Match match in r.Matches(inputs.YieldWord()))
|
||||||
{
|
{
|
||||||
|
if(this.ignoreEmptyMatches && string.IsNullOrEmpty(match.Value))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var newToken = new FragmentToken(match.Value);
|
var newToken = new FragmentToken(match.Value);
|
||||||
// token contains data from all included matches
|
// token contains data from all included matches
|
||||||
foreach (var groupName in this.namedGroups)
|
foreach (var groupName in this.namedGroups)
|
||||||
@@ -109,4 +115,9 @@ public class FragmentSchema : ISchema<FragmentSchemaContext>
|
|||||||
{
|
{
|
||||||
return new FragmentSchemaContext();
|
return new FragmentSchemaContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShouldIgnoreEmptyMatches(bool ignoreEmptyMatches)
|
||||||
|
{
|
||||||
|
this.ignoreEmptyMatches = ignoreEmptyMatches;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,22 @@ public class FragmentSchemaBuilder : RepetitionSchemaBuilder<FragmentSchemaBuild
|
|||||||
case InputType.Integer:
|
case InputType.Integer:
|
||||||
this.fragmentRegex += "(" + groupNamePrefix + "\\d+)";
|
this.fragmentRegex += "(" + groupNamePrefix + "\\d+)";
|
||||||
break;
|
break;
|
||||||
|
case InputType.Char:
|
||||||
|
this.fragmentRegex += "(" + groupNamePrefix + "[a-zA-Z])";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unrecognized InputType");
|
throw new Exception("Unrecognized InputType");
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FragmentSchemaBuilder ShouldIgnoreEmptyMatches(bool ignoreEmptyMatches)
|
||||||
|
{
|
||||||
|
this.ShouldIgnoreEmptyMatches(ignoreEmptyMatches);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public FragmentSchemaBuilder Expect(string literal, string name = "")
|
public FragmentSchemaBuilder Expect(string literal, string name = "")
|
||||||
{
|
{
|
||||||
string groupNamePrefix = "";
|
string groupNamePrefix = "";
|
||||||
@@ -130,6 +140,10 @@ public class FragmentSchemaBuilder : RepetitionSchemaBuilder<FragmentSchemaBuild
|
|||||||
}
|
}
|
||||||
|
|
||||||
oldSchemaBuilder.fragmentRegex += "(" + currentRegex + ")";
|
oldSchemaBuilder.fragmentRegex += "(" + currentRegex + ")";
|
||||||
|
var groupsToAdd = currentBuilder.namedGroups.Where(g => !oldSchemaBuilder.namedGroups.Contains(g)).ToList();
|
||||||
|
var literalsToAdd = currentBuilder.namedLiterals.Where(l => !oldSchemaBuilder.namedLiterals.Contains(l)).ToList();
|
||||||
|
oldSchemaBuilder.namedGroups.AddRange(groupsToAdd);
|
||||||
|
oldSchemaBuilder.namedLiterals.AddRange(literalsToAdd);
|
||||||
|
|
||||||
return oldSchemaBuilder;
|
return oldSchemaBuilder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.10.0
|
0.12.0
|
||||||
|
|||||||
@@ -8,4 +8,8 @@
|
|||||||
<add key="gitea-homelab" value="https://git.disi.dev/api/packages/Homelab/nuget/index.json" />
|
<add key="gitea-homelab" value="https://git.disi.dev/api/packages/Homelab/nuget/index.json" />
|
||||||
<add key="gitea-artifacts" value="https://git.disi.dev/api/packages/Artifacts/nuget/index.json" />
|
<add key="gitea-artifacts" value="https://git.disi.dev/api/packages/Artifacts/nuget/index.json" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
|
|
||||||
|
<config>
|
||||||
|
<add key="DefaultPushSource" value="https://git.disi.dev/api/packages/Projects/nuget/index.json" />
|
||||||
|
</config>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Reference in New Issue
Block a user