Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions ExtensibleParaser/ExtensibleParaser.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Regex\Regex\Regex.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<!--<ItemGroup>
<PackageReference Include="IsExternalInit" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>-->

<ItemGroup>
<Compile Include="..\Shared\NetStandard2_0Support.cs" Link="Shared\NetStandard2_0Support.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Regex\Regex\Regex.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Shared\" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion ExtensibleParaser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
return Result.Success(new SeqNode(zeroOrMany.Kind ?? "ZeroOrMany", elements, startPos, currentPos), currentPos, maxFailPos);
}

private static ReadOnlySpan<char> Preview(string input, int pos, int len = 5) => pos >= input.Length
private static ChatRef Preview(string input, int pos, int len = 5) => pos >= input.Length
? "«»"
: $"«{input.AsSpan(pos, Math.Min(input.Length - pos, len))}»";

Expand Down Expand Up @@ -528,7 +528,7 @@
maxFailPos: currentPos // ???
);

Result panicRecovery(Terminal terminal, int startPos, string input)

Check warning on line 531 in ExtensibleParaser/Parser.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows-latest

The local function 'panicRecovery' is declared but never used

Check warning on line 531 in ExtensibleParaser/Parser.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest

The local function 'panicRecovery' is declared but never used

Check warning on line 531 in ExtensibleParaser/Parser.cs

View workflow job for this annotation

GitHub Actions / build-and-test-macOS-latest

The local function 'panicRecovery' is declared but never used
{
Log($"Starting recovery for terminal {terminal.Kind} at position {startPos}");
var currentRule = _ruleStack.Peek();
Expand Down
9 changes: 5 additions & 4 deletions ExtensibleParaser/SyntaxTree.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;

using System.Diagnostics;

namespace ExtensibleParaser;

Expand All @@ -9,7 +10,7 @@ public interface ISyntaxNode
int EndPos { get; }
bool IsRecovery { get; }
void Accept(ISyntaxVisitor visitor);
ReadOnlySpan<char> AsSpan(string input);
ChatRef AsSpan(string input);
string ToString(string input);
}

Expand All @@ -26,7 +27,7 @@ public interface ISyntaxVisitor
public abstract record Node(string Kind, int StartPos, int EndPos, bool IsRecovery = false) : ISyntaxNode
{
public int Length => EndPos - StartPos;
public virtual ReadOnlySpan<char> AsSpan(string input) => input.AsSpan(StartPos, EndPos - StartPos);
public virtual ChatRef AsSpan(string input) => input.AsSpan(StartPos, EndPos - StartPos);
public virtual string ToString(string input) => input[StartPos..EndPos];
public abstract void Accept(ISyntaxVisitor visitor);

Expand Down Expand Up @@ -64,7 +65,7 @@ private sealed class DebugView(Node node)

public record TerminalNode(string Kind, int StartPos, int EndPos, int ContentLength, bool IsRecovery = false) : Node(Kind, StartPos, EndPos, IsRecovery)
{
public override ReadOnlySpan<char> AsSpan(string input) => input.AsSpan(StartPos, ContentLength);
public override ChatRef AsSpan(string input) => input.AsSpan(StartPos, ContentLength);
public override string ToString(string input) => input.Substring(StartPos, ContentLength);
public override void Accept(ISyntaxVisitor visitor) => visitor.Visit(this);
public override string ToString() => $"{Kind}Terminal([{StartPos},{StartPos + ContentLength}), «{DebugContent() ?? Kind}»)";
Expand Down
4 changes: 2 additions & 2 deletions Parsers/DotParser/DotAst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public record DotIdentifier(string Value, int StartPos, int EndPos) : DotTermina
public record DotQuotedString(string Value, string RawValue, int StartPos, int EndPos)
: DotTerminalNode(Kind: "QuotedString", StartPos: StartPos, EndPos: EndPos)
{
public DotQuotedString(ReadOnlySpan<char> span, int startPos, int endPos)
public DotQuotedString(ChatRef span, int startPos, int endPos)
: this(Value: ProcessQuotedString(span), RawValue: span[1..^1].ToString(), StartPos: startPos, EndPos: endPos)
{
}

private static string ProcessQuotedString(ReadOnlySpan<char> span)
private static string ProcessQuotedString(ChatRef span)
{
var content = span[1..^1];
var result = new StringBuilder();
Expand Down
31 changes: 20 additions & 11 deletions Parsers/DotParser/DotParser.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Dot</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<RootNamespace>Dot</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ExtensibleParaser\ExtensibleParaser.csproj" />
<ProjectReference Include="..\..\Regex\Regex\Regex.csproj" OutputItemType="Analyzer" />
<ProjectReference Include="..\..\TerminalGenerator\TerminalGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\NetStandard2_0Support.cs" Link="Shared\NetStandard2_0Support.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\ExtensibleParaser\ExtensibleParaser.csproj" />
<ProjectReference Include="..\..\Regex\Regex\Regex.csproj" OutputItemType="Analyzer" />
<ProjectReference Include="..\..\TerminalGenerator\TerminalGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
<Folder Include="Shared\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Parsers/DotParser/DotVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void Visit(SeqNode node)
return;
DotAttribute[] getAttributes(List<DotAst> children)
{
if (children is [DotLiteral { Value: "[" }, .. var attributes, DotLiteral { Value: "]" }])
if (children.ToArray() is [DotLiteral { Value: "[" }, .. var attributes, DotLiteral { Value: "]" }])
return attributes.SelectMany(x => x switch
{
DotAttribute a => [a],
Expand Down
28 changes: 0 additions & 28 deletions Regex/Regex/CompilerServices/Extensions.cs

This file was deleted.

55 changes: 0 additions & 55 deletions Regex/Regex/CompilerServices/Index.cs

This file was deleted.

9 changes: 9 additions & 0 deletions Regex/Regex/Regex.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\Shared\NetStandard2_0Support.cs" Link="Shared\NetStandard2_0Support.cs" />
<Compile Include="..\..\Shared\StringExtensions.cs" Link="Shared\StringExtensions.cs" />
</ItemGroup>

<!--<ItemGroup>
<PackageReference Include="IsExternalInit" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>-->

<ItemGroup>
<Folder Include="Shared\" />
</ItemGroup>

</Project>
Loading