Skip to content

Commit 9a813c5

Browse files
authored
Move core projects to netstandard2.0 to support internal source generators (#7)
Move core projects to netstandard2.0 to support internal source generators
1 parent 547b56f commit 9a813c5

File tree

13 files changed

+603
-129
lines changed

13 files changed

+603
-129
lines changed
Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<LangVersion>preview</LangVersion>
8-
</PropertyGroup>
9-
10-
<ItemGroup>
11-
<ProjectReference Include="..\Regex\Regex\Regex.csproj" />
12-
</ItemGroup>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<LangVersion>preview</LangVersion>
8+
</PropertyGroup>
9+
10+
<!--<ItemGroup>
11+
<PackageReference Include="IsExternalInit" Version="1.0.3">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
</ItemGroup>-->
16+
17+
<ItemGroup>
18+
<Compile Include="..\Shared\NetStandard2_0Support.cs" Link="Shared\NetStandard2_0Support.cs" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<ProjectReference Include="..\Regex\Regex\Regex.csproj" />
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<Folder Include="Shared\" />
27+
</ItemGroup>
1328
</Project>

ExtensibleParaser/Parser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ private Result ParseZeroOrMany(ZeroOrMany zeroOrMany, int startPos, string input
481481
return Result.Success(new SeqNode(zeroOrMany.Kind ?? "ZeroOrMany", elements, startPos, currentPos), currentPos, maxFailPos);
482482
}
483483

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

ExtensibleParaser/SyntaxTree.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics;
1+

2+
using System.Diagnostics;
23

34
namespace ExtensibleParaser;
45

@@ -9,7 +10,7 @@ public interface ISyntaxNode
910
int EndPos { get; }
1011
bool IsRecovery { get; }
1112
void Accept(ISyntaxVisitor visitor);
12-
ReadOnlySpan<char> AsSpan(string input);
13+
ChatRef AsSpan(string input);
1314
string ToString(string input);
1415
}
1516

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

@@ -64,7 +65,7 @@ private sealed class DebugView(Node node)
6465

6566
public record TerminalNode(string Kind, int StartPos, int EndPos, int ContentLength, bool IsRecovery = false) : Node(Kind, StartPos, EndPos, IsRecovery)
6667
{
67-
public override ReadOnlySpan<char> AsSpan(string input) => input.AsSpan(StartPos, ContentLength);
68+
public override ChatRef AsSpan(string input) => input.AsSpan(StartPos, ContentLength);
6869
public override string ToString(string input) => input.Substring(StartPos, ContentLength);
6970
public override void Accept(ISyntaxVisitor visitor) => visitor.Visit(this);
7071
public override string ToString() => $"{Kind}Terminal([{StartPos},{StartPos + ContentLength}), «{DebugContent() ?? Kind}»)";

Parsers/DotParser/DotAst.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public record DotIdentifier(string Value, int StartPos, int EndPos) : DotTermina
5555
public record DotQuotedString(string Value, string RawValue, int StartPos, int EndPos)
5656
: DotTerminalNode(Kind: "QuotedString", StartPos: StartPos, EndPos: EndPos)
5757
{
58-
public DotQuotedString(ReadOnlySpan<char> span, int startPos, int endPos)
58+
public DotQuotedString(ChatRef span, int startPos, int endPos)
5959
: this(Value: ProcessQuotedString(span), RawValue: span[1..^1].ToString(), StartPos: startPos, EndPos: endPos)
6060
{
6161
}
6262

63-
private static string ProcessQuotedString(ReadOnlySpan<char> span)
63+
private static string ProcessQuotedString(ChatRef span)
6464
{
6565
var content = span[1..^1];
6666
var result = new StringBuilder();

Parsers/DotParser/DotParser.csproj

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<RootNamespace>Dot</RootNamespace>
8-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<LangVersion>preview</LangVersion>
8+
<RootNamespace>Dot</RootNamespace>
9+
</PropertyGroup>
910

10-
<ItemGroup>
11-
<ProjectReference Include="..\..\ExtensibleParaser\ExtensibleParaser.csproj" />
12-
<ProjectReference Include="..\..\Regex\Regex\Regex.csproj" OutputItemType="Analyzer" />
13-
<ProjectReference Include="..\..\TerminalGenerator\TerminalGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
14-
</ItemGroup>
11+
<ItemGroup>
12+
<Compile Include="..\..\Shared\NetStandard2_0Support.cs" Link="Shared\NetStandard2_0Support.cs" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\ExtensibleParaser\ExtensibleParaser.csproj" />
17+
<ProjectReference Include="..\..\Regex\Regex\Regex.csproj" OutputItemType="Analyzer" />
18+
<ProjectReference Include="..\..\TerminalGenerator\TerminalGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Folder Include="Shared\" />
23+
</ItemGroup>
1524

1625
</Project>

Parsers/DotParser/DotVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void Visit(SeqNode node)
7474
return;
7575
DotAttribute[] getAttributes(List<DotAst> children)
7676
{
77-
if (children is [DotLiteral { Value: "[" }, .. var attributes, DotLiteral { Value: "]" }])
77+
if (children.ToArray() is [DotLiteral { Value: "[" }, .. var attributes, DotLiteral { Value: "]" }])
7878
return attributes.SelectMany(x => x switch
7979
{
8080
DotAttribute a => [a],

Regex/Regex/CompilerServices/Extensions.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

Regex/Regex/CompilerServices/Index.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

Regex/Regex/Regex.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<Compile Include="..\..\Shared\NetStandard2_0Support.cs" Link="Shared\NetStandard2_0Support.cs" />
12+
<Compile Include="..\..\Shared\StringExtensions.cs" Link="Shared\StringExtensions.cs" />
13+
</ItemGroup>
14+
15+
<!--<ItemGroup>
1116
<PackageReference Include="IsExternalInit" Version="1.0.3">
1217
<PrivateAssets>all</PrivateAssets>
1318
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1419
</PackageReference>
20+
</ItemGroup>-->
21+
22+
<ItemGroup>
23+
<Folder Include="Shared\" />
1524
</ItemGroup>
1625

1726
</Project>

0 commit comments

Comments
 (0)