diff --git a/StgSharp.Native/CMakeLists.txt b/StgSharp.Native/CMakeLists.txt index 82489612..85ebb376 100644 --- a/StgSharp.Native/CMakeLists.txt +++ b/StgSharp.Native/CMakeLists.txt @@ -49,7 +49,7 @@ else() set(STGSHARP_ARCH_TAG ${SN_RESOLVED_ARCH_NAME}) endif() -set(STGSHARP_BUILD_OUTPUT_DIR ${STGSHARP_SOLUTION_ROOT}/build/${STGSHARP_OS_TAG}-${STGSHARP_ARCH_TAG}) +set(STGSHARP_BUILD_OUTPUT_DIR ${STGSHARP_SOLUTION_ROOT}/cmake_build/${STGSHARP_OS_TAG}_${STGSHARP_ARCH_TAG}) set(STGSHARP_OBJECT_ROOT_DIR ${STGSHARP_SOLUTION_ROOT}/obj/${PROJECT_NAME}) set(STGSHARP_NATIVE_PROJECT_FILES ${STGSHARP_NATIVE_SOURCES} diff --git a/StgSharp.Native/sn-src/mk.fma.x86.c b/StgSharp.Native/sn-src/mk.fma.x86.c index eebdc2c2..57040a79 100644 --- a/StgSharp.Native/sn-src/mk.fma.x86.c +++ b/StgSharp.Native/sn-src/mk.fma.x86.c @@ -125,11 +125,11 @@ SN_MK_PROC_DECL_STD(float, avx, _fma, fma) register __m256 a1 = _mm256_load_ps((float *)&a_base->y[1]); register __m256 a2 = _mm256_load_ps((float *)&a_base->y[2]); register __m256 a3 = _mm256_load_ps((float *)&a_base->y[3]); - - SN_MK_FMA_F32_AVX2_FMA_CYCLE(0); - SN_MK_FMA_F32_AVX2_FMA_CYCLE(1); - SN_MK_FMA_F32_AVX2_FMA_CYCLE(2); - SN_MK_FMA_F32_AVX2_FMA_CYCLE(3); + + SN_MK_FMA_F32_AVX2_CYCLE(0); + SN_MK_FMA_F32_AVX2_CYCLE(1); + SN_MK_FMA_F32_AVX2_CYCLE(2); + SN_MK_FMA_F32_AVX2_CYCLE(3); } _mm256_store_ps((float *)&(ans_cur->y[0]), c0); _mm256_store_ps((float *)&(ans_cur->y[1]), c1); diff --git a/StgSharp.Native/sn-template/sn_template.fma.x86.h b/StgSharp.Native/sn-template/sn_template.fma.x86.h index 47f4f699..a9c59adf 100644 --- a/StgSharp.Native/sn-template/sn_template.fma.x86.h +++ b/StgSharp.Native/sn-template/sn_template.fma.x86.h @@ -2,36 +2,55 @@ #if SN_IS_ARCH(SN_ARCH_X86_64) -#define SN_MK_FMA_F32_512_CYCLE(i) \ - do { \ - c0 = _mm512_fmadd_ps(a0, _mm512_permute_ps(b0, _FMA_SELECT(i)), c0); \ - c1 = _mm512_fmadd_ps(a1, _mm512_permute_ps(b1, _FMA_SELECT(i)), c1); \ - c2 = _mm512_fmadd_ps(a2, _mm512_permute_ps(b2, _FMA_SELECT(i)), c2); \ - c3 = _mm512_fmadd_ps(a3, _mm512_permute_ps(b3, _FMA_SELECT(i)), c3); \ +#define SN_MK_FMA_F32_512_CYCLE(i) \ + do { \ + c0 = _mm512_fmadd_ps(c0, a0, _mm512_permute_ps(b0, _FMA_SELECT(i))); \ + c1 = _mm512_fmadd_ps(c1, a1, _mm512_permute_ps(b1, _FMA_SELECT(i))); \ + c2 = _mm512_fmadd_ps(c2, a2, _mm512_permute_ps(b2, _FMA_SELECT(i))); \ + c3 = _mm512_fmadd_ps(c3, a3, _mm512_permute_ps(b3, _FMA_SELECT(i))); \ } while (0) -#define SN_MK_FMA_F32_AVX2_FMA_CYCLE(i) \ - do { \ - c0 = _mm256_fmadd_ps(a0, _mm256_permute_ps(b0, _FMA_SELECT(i)), c0); \ - c1 = _mm256_fmadd_ps(a1, _mm256_permute_ps(b1, _FMA_SELECT(i)), c1); \ - c2 = _mm256_fmadd_ps(a2, _mm256_permute_ps(b2, _FMA_SELECT(i)), c2); \ - c3 = _mm256_fmadd_ps(a3, _mm256_permute_ps(b3, _FMA_SELECT(i)), c3); \ +#define SN_MK_FMA_F32_AVX2_CYCLE(i) \ + do { \ + c0 = _mm256_fmadd_ps(c0, a0, _mm256_permute_ps(b0, _FMA_SELECT(i))); \ + c1 = _mm256_fmadd_ps(c1, a1, _mm256_permute_ps(b1, _FMA_SELECT(i))); \ + c2 = _mm256_fmadd_ps(c2, a2, _mm256_permute_ps(b2, _FMA_SELECT(i))); \ + c3 = _mm256_fmadd_ps(c3, a3, _mm256_permute_ps(b3, _FMA_SELECT(i))); \ } while (0) -#define SN_MK_FMA_F32_AVX2_CYCLE(i) \ - do { \ - c0 = _mm256_add_ps(_mm256_mul_ps(a0, _mm256_permute_ps(b0, _FMA_SELECT(i))), c0); \ - c1 = _mm256_add_ps(_mm256_mul_ps(a1, _mm256_permute_ps(b1, _FMA_SELECT(i))), c1); \ - c2 = _mm256_add_ps(_mm256_mul_ps(a2, _mm256_permute_ps(b2, _FMA_SELECT(i))), c2); \ - c3 = _mm256_add_ps(_mm256_mul_ps(a3, _mm256_permute_ps(b3, _FMA_SELECT(i))), c3); \ +#define SN_MK_FMA_F64_AVX2_CYCLE(i) \ + do { \ + c0 = _mm512_fmadd_ps(c0, a0, _mm512_permutex_pd(b0, _FMA_SELECT(i))); \ + c1 = _mm512_fmadd_ps(c1, a1, _mm512_permutex_pd(b1, _FMA_SELECT(i))); \ + c2 = _mm512_fmadd_ps(c2, a2, _mm512_permutex_pd(b2, _FMA_SELECT(i))); \ + c3 = _mm512_fmadd_ps(c3, a3, _mm512_permutex_pd(b3, _FMA_SELECT(i))); \ } while (0) -#define SN_MK_FMA_F64_AVX2_CYCLE(i) \ - do { \ - c0 = _mm512_fmadd_ps(a0, _mm512_permutex_pd(b0, _FMA_SELECT(i)), c0); \ - c1 = _mm512_fmadd_ps(a1, _mm512_permutex_pd(b1, _FMA_SELECT(i)), c1); \ - c2 = _mm512_fmadd_ps(a2, _mm512_permutex_pd(b2, _FMA_SELECT(i)), c2); \ - c3 = _mm512_fmadd_ps(a3, _mm512_permutex_pd(b3, _FMA_SELECT(i)), c3); \ +#define SN_FMA_F32_512_PACK_COLUMN(col, target) \ + do { \ + register __m256 low = _mm512_castps512_ps256(col); \ + register __m256 high = _mm512_extractf32x8_ps(col, 1); \ + register __m256 half = _mm256_add_ps(high, low); \ + register __m128 high128 = _mm256_extractf32x4_ps(half, 1); \ + register __m128 low128 = _mm256_castps256_ps128(half); \ + register __m128 half128 = _mm_add_ps(high128, low128); \ + _mm_store_ps(target, half128); \ + } while (0) + +#define SN_FMA_F32_AVX2_PACK_COLUMN(col, target) \ + do { \ + register __m128 high128 = _mm256_extractf32x4_ps(col, 1); \ + register __m128 low128 = _mm256_castps256_ps128(col); \ + register __m128 half128 = _mm_add_ps(high128, low128); \ + _mm_store_ps(target, half128); \ + } while (0) + +#define SN_FMA_F64_512_PACK_COLUMN(col, target) \ + do { \ + register __m128 high128 = _mm256_extractf32x4_ps(col, 1); \ + register __m128 low128 = _mm256_castps256_ps128(col); \ + register __m128 half128 = _mm_add_ps(high128, low128); \ + _mm_store_ps(target, half128); \ } while (0) // double diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexAstNode.cs b/StgSharp.RegularAnalysis/TextRegex/RegexAstNode.cs index 9b6de712..ffa6da9e 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexAstNode.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexAstNode.cs @@ -28,16 +28,14 @@ using StgSharp.RegularAnalysis.Abstraction; using System.Runtime.CompilerServices; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { internal class RegexAstNode : ISyntaxNode { // private RegexAstNode _left, _right; - public RegexAstNode( - Token source - ) + public RegexAstNode(Token source) { Source = source; } @@ -89,19 +87,14 @@ namespace StgSharp.RegularAnalysis.TextRegex public Token Source { get; private protected set; } - public void AppendNode( - RegexAstNode nextToken - ) + public void AppendNode(RegexAstNode nextToken) { Next = nextToken; nextToken.Previous = this; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static (bool Valid, int Value) ComparePrecedence( - RegexElementLabel left, - RegexElementLabel right - ) + public static (bool Valid, int Value) ComparePrecedence(RegexElementLabel left, RegexElementLabel right) { left &= RegexElementLabel.OPERATOR; right &= RegexElementLabel.OPERATOR; @@ -113,25 +106,19 @@ namespace StgSharp.RegularAnalysis.TextRegex } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsNullOrEmpty( - RegexAstNode node - ) + public static bool IsNullOrEmpty(RegexAstNode node) { return node is null || ReferenceEquals(node, Empty); } /**/ - public void PrependNode( - RegexAstNode previousNode - ) + public void PrependNode(RegexAstNode previousNode) { Previous = previousNode; previousNode.Next = this; } - public void RemoveChild( - RegexAstNode node - ) + public void RemoveChild(RegexAstNode node) { if (Left == node) { @@ -149,9 +136,7 @@ namespace StgSharp.RegularAnalysis.TextRegex return new EmptyRegexAstNode(); } - internal void RemoveAndAsChild( - bool useLeft - ) + internal void RemoveAndAsChild(bool useLeft) { if (useLeft) { @@ -176,9 +161,7 @@ namespace StgSharp.RegularAnalysis.TextRegex /// /// The node to replace the current node with. /// - internal void ReplaceBy( - RegexAstNode node - ) + internal void ReplaceBy(RegexAstNode node) { Source = node.Source; Left = node.Left; diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexElementLabel.cs b/StgSharp.RegularAnalysis/TextRegex/RegexElementLabel.cs index dec57691..96e3b61b 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexElementLabel.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexElementLabel.cs @@ -31,7 +31,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { [Flags] public enum RegexElementLabel diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexIR.cs b/StgSharp.RegularAnalysis/TextRegex/RegexIR.cs index 46498c96..ecea4f6e 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexIR.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexIR.cs @@ -32,7 +32,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { internal enum RegexIRCommand { diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexIRGenerator.cs b/StgSharp.RegularAnalysis/TextRegex/RegexIRGenerator.cs index e5afb6ee..541a02f3 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexIRGenerator.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexIRGenerator.cs @@ -32,7 +32,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { internal class RegexIRGenerator { diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.IRGenerate.cs b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.IREmit.cs similarity index 96% rename from StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.IRGenerate.cs rename to StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.IREmit.cs index 7c7e77a2..e3e8b1f6 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.IRGenerate.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.IREmit.cs @@ -1,6 +1,6 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="RegexInterpreter.IRGenerate" +// file="RegexInterpreter.IREmit" // Project: StgSharp // AuthorGroup: Nitload // Copyright (c) Nitload. All rights reserved. @@ -38,14 +38,12 @@ using System.Text; using System.Threading.Tasks; using System.Xml; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { public partial class RegexInterpreter { - internal static List GenerateIR( - AbstractSyntaxTree tree - ) + internal static List GenerateIR(AbstractSyntaxTree tree) { return GenerateIRRecursion(tree.Root, 0).ToList(); } @@ -57,8 +55,7 @@ namespace StgSharp.RegularAnalysis.TextRegex int min, int max, bool isGreedy, - RegexAstNode right - ) + RegexAstNode right) { bool isRightOperator = !RegexAstNode.IsNullOrEmpty(right) && (right.Source.Flag & RegexElementLabel.OPERATOR) != 0; @@ -89,10 +86,7 @@ namespace StgSharp.RegularAnalysis.TextRegex } } - private static RegexIRGenerator GenerateIRRecursion( - RegexAstNode node, - int depth - ) + private static RegexIRGenerator GenerateIRRecursion(RegexAstNode node, int depth) { #pragma warning disable IDE0010 if (depth > 1024) diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.Optimize.cs b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.Optimize.cs index 6e7bbb80..36398174 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.Optimize.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.Optimize.cs @@ -37,7 +37,7 @@ using System.Text; using System.Threading.Tasks; using System.Xml.Linq; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { public partial class RegexInterpreter { diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.SourceEmit.cs b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.SourceEmit.cs new file mode 100644 index 00000000..efd7f319 --- /dev/null +++ b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.SourceEmit.cs @@ -0,0 +1,37 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="RegexInterpreter.SourceEmit" +// Project: StgSharp +// AuthorGroup: Nitload +// Copyright (c) Nitload. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.RegularAnalysis.Text +{ + public partial class RegexInterpreter { } +} diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.cs b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.cs index 0a5cfbdc..21f2119f 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexInterpreter.cs @@ -35,7 +35,7 @@ using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { public partial class RegexInterpreter { @@ -58,9 +58,7 @@ namespace StgSharp.RegularAnalysis.TextRegex } } - public static RegexInterpreter Analyze( - string regex - ) + public static RegexInterpreter Analyze(string regex) { RegexInterpreter interpreter = new(); interpreter._source = regex; @@ -222,14 +220,11 @@ namespace StgSharp.RegularAnalysis.TextRegex // TODO enum AST again , do ALT tail merge and simple ALT front merge } - private void ProcessOperator( - RegexAstNode op - ) + private void ProcessOperator(RegexAstNode op) { if (op.EqualityTypeConvert == RegexElementLabel.CONCAT) { - if (_stack.TryPopOperand(out RegexAstNode? _1) && - _stack.TryPopOperand(out RegexAstNode? _2)) + if (_stack.TryPopOperand(out RegexAstNode? _1) && _stack.TryPopOperand(out RegexAstNode? _2)) { op.Left = _2; op.Right = _1; @@ -255,8 +250,7 @@ namespace StgSharp.RegularAnalysis.TextRegex } } else if (op.EqualityTypeConvert == RegexElementLabel.ALT) { - if (_stack.TryPopOperand(out RegexAstNode? _1) && - _stack.TryPopOperand(out RegexAstNode? _2)) + if (_stack.TryPopOperand(out RegexAstNode? _1) && _stack.TryPopOperand(out RegexAstNode? _2)) { op.Left = _2; op.Right = _1; diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexTokenParser.cs b/StgSharp.RegularAnalysis/TextRegex/RegexTokenParser.cs index 452a65a1..f4ee54a3 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexTokenParser.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexTokenParser.cs @@ -34,7 +34,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { internal class RegexTokenParser : TokenParser { diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexTokenReader.cs b/StgSharp.RegularAnalysis/TextRegex/RegexTokenReader.cs index d57f3518..ada15d54 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexTokenReader.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexTokenReader.cs @@ -34,7 +34,7 @@ using System.Security.Permissions; using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { internal class RegexTokenReader : ITokenReader { @@ -45,9 +45,7 @@ namespace StgSharp.RegularAnalysis.TextRegex public RegexTokenReader() { } - public RegexTokenReader( - string source - ) + public RegexTokenReader(string source) { _source = source; } @@ -67,11 +65,9 @@ namespace StgSharp.RegularAnalysis.TextRegex { string value = _source[(pos + 1)..(pos + 3)]; pos += 4; - if (uint.TryParse(value, out uint code) && - Rune.TryCreate(code, out Rune result)) + if (uint.TryParse(value, out uint code) && Rune.TryCreate(code, out Rune result)) { - return new Token(result.ToString(), 0, pos, - RegexElementLabel.UNIT); + return new Token(result.ToString(), 0, pos, RegexElementLabel.UNIT); } else { throw new InvalidCastException($"Failed to convert {value} to a valid ascii code point."); @@ -80,11 +76,9 @@ namespace StgSharp.RegularAnalysis.TextRegex { string value = _source[(pos + 1)..(pos + 5)]; pos += 6; - if (uint.TryParse(value, out uint code) && - Rune.TryCreate(code, out Rune result)) + if (uint.TryParse(value, out uint code) && Rune.TryCreate(code, out Rune result)) { - return new Token(result.ToString(), 0, pos, - RegexElementLabel.UNIT); + return new Token(result.ToString(), 0, pos, RegexElementLabel.UNIT); } else { throw new InvalidCastException($"Failed to convert {value} to a valid unicode code point."); @@ -118,24 +112,21 @@ namespace StgSharp.RegularAnalysis.TextRegex { int length = (i - pos - 1); position = i + 1; - return new Token(_source[(pos)..(i + 1)], 0, - position, + return new Token(_source[(pos)..(i + 1)], 0, position, RegexElementLabel.UNIT_SET); } } throw new InvalidOperationException("Unclosed character set"); case '|': position = pos + 1; - return new Token(_source[(pos)..(pos + 1)], 0, pos, - RegexElementLabel.ALT); + return new Token(_source[(pos)..(pos + 1)], 0, pos, RegexElementLabel.ALT); case '(': // very comlex here return ReadGroupBeginToken(); case ')': position = pos + 1; - return new Token(_source[(pos)..(pos + 1)], 0, pos, - RegexElementLabel.GROUP_END); + return new Token(_source[(pos)..(pos + 1)], 0, pos, RegexElementLabel.GROUP_END); case '{': for (int i = pos + 1; i < _source.Length; i++) { @@ -150,26 +141,20 @@ namespace StgSharp.RegularAnalysis.TextRegex case '*' or '+': int count = pos + 1 >= _source.Length ? 1 : (_source[pos + 1] == '?' ? 2 : 1); position = pos + count; - return new Token(_source[(pos)..(pos + count)], 0, pos, - RegexElementLabel.COUNT); + return new Token(_source[(pos)..(pos + count)], 0, pos, RegexElementLabel.COUNT); case '?': position = pos + 1; - return new Token(_source[(pos)..(pos + 1)], 0, pos, - RegexElementLabel.COUNT); + return new Token(_source[(pos)..(pos + 1)], 0, pos, RegexElementLabel.COUNT); case '.': position = pos + 1; - return new Token(_source[(pos)..(pos + 1)], 0, pos, - RegexElementLabel.UNIT); + return new Token(_source[(pos)..(pos + 1)], 0, pos, RegexElementLabel.UNIT); default: position = pos + 1; - return new Token(_source[(pos)..(pos + 1)], 0, pos, - RegexElementLabel.UNIT); + return new Token(_source[(pos)..(pos + 1)], 0, pos, RegexElementLabel.UNIT); } } - public bool TryReadToken( - out Token t - ) + public bool TryReadToken(out Token t) { if (IsEmpty) { diff --git a/StgSharp.RegularAnalysis/TextRegex/RegexTokenUtil.cs b/StgSharp.RegularAnalysis/TextRegex/RegexTokenUtil.cs index 3d51ab3c..1a32cc24 100644 --- a/StgSharp.RegularAnalysis/TextRegex/RegexTokenUtil.cs +++ b/StgSharp.RegularAnalysis/TextRegex/RegexTokenUtil.cs @@ -32,7 +32,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StgSharp.RegularAnalysis.TextRegex +namespace StgSharp.RegularAnalysis.Text { internal static class RegexTokenUtil { diff --git a/StgSharp.RegularAnalysis/TextRegex/TextRegex.cs b/StgSharp.RegularAnalysis/TextRegex/TextRegex.cs new file mode 100644 index 00000000..deafa82e --- /dev/null +++ b/StgSharp.RegularAnalysis/TextRegex/TextRegex.cs @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="TextRegex" +// Project: StgSharp +// AuthorGroup: Nitload +// Copyright (c) Nitload. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.RegularAnalysis.Text +{ + public abstract class TextRegex + { + public ref struct Match + { + private ReadOnlySpan _sequence; + + + } + } +} diff --git a/StgSharpDebug/Program.cs b/StgSharpDebug/Program.cs index bef92bbd..18a17107 100644 --- a/StgSharpDebug/Program.cs +++ b/StgSharpDebug/Program.cs @@ -32,17 +32,18 @@ using StgSharp.Mathematics; using StgSharp.Mathematics.Numeric; using StgSharp.Timing; using StgSharp.Timing; +using System; namespace StgSharp { internal static partial class Program { + private static bool _hasError; + private static string testExpPath = @"D:\Programmer\stepcode\data\ap203\ap203.exp"; - internal static unsafe void Main( - string[] args - ) + internal static unsafe void Main(string[] args) { try { @@ -63,12 +64,13 @@ namespace StgSharp // TestMatrix(); - /* + /**/ } catch (Exception ex) { Console.WriteLine(ex); - Console.ReadLine(); + _ = Console.ReadLine(); + _hasError = true; /* World.WriteLog($"{ex}", LogType.Error); Dialogue.PostError(ex); @@ -79,6 +81,11 @@ namespace StgSharp } finally { + if (!_hasError) + { + Console.WriteLine("Program has exited with no error, press any key to exit."); + _ = Console.ReadKey(); + } World.Terminate(0); } /**/ diff --git a/StgSharpDebug/TestRegexAnalyse.cs b/StgSharpDebug/TestRegexAnalyse.cs index 7d9e80d9..0215c18c 100644 --- a/StgSharpDebug/TestRegexAnalyse.cs +++ b/StgSharpDebug/TestRegexAnalyse.cs @@ -26,7 +26,7 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using StgSharp.RegularAnalysis.Abstraction; -using StgSharp.RegularAnalysis.TextRegex; +using StgSharp.RegularAnalysis.Text; using System; using System.Collections.Generic; using System.Linq; @@ -44,8 +44,7 @@ namespace StgSharp @"abc[0-9]x|abc[0-9]y|abd[0-9]x|abd[0-9]y|xyz", @"get_name|get_value|get_type|set_name|set_value|set_type", @"helix|hello|help|hero|hers|her", - @"a*.[abc]*(abcd|a(bc)c)+(?abc)" - ]; + @"a*.[abc]*(abcd|a(bc)c)+(?abc)"]; public static void Run() {