Skip to content

Commit

Permalink
Merge branch 'main' into sebros/seek
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored May 9, 2024
2 parents b480cb6 + 1327d24 commit 806c61c
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 4 deletions.
15 changes: 15 additions & 0 deletions Parlot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "src\Samples\Samples.csproj", "{B9A796FE-4BEB-499A-B506-25F20C749527}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -68,6 +70,18 @@ Global
{3DF3E827-7AEE-4130-9925-D6DB26C420CC}.Release|x64.Build.0 = Release|Any CPU
{3DF3E827-7AEE-4130-9925-D6DB26C420CC}.Release|x86.ActiveCfg = Release|Any CPU
{3DF3E827-7AEE-4130-9925-D6DB26C420CC}.Release|x86.Build.0 = Release|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Debug|x64.ActiveCfg = Debug|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Debug|x64.Build.0 = Debug|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Debug|x86.ActiveCfg = Debug|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Debug|x86.Build.0 = Debug|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Release|Any CPU.Build.0 = Release|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Release|x64.ActiveCfg = Release|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Release|x64.Build.0 = Release|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Release|x86.ActiveCfg = Release|Any CPU
{B9A796FE-4BEB-499A-B506-25F20C749527}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -76,6 +90,7 @@ Global
{44F5D7FE-63A0-45BD-B743-9711C273B5A2} = {0D1E6480-3C81-4951-8F44-BF74398BA8D4}
{9452A111-5A01-4D3C-AA9F-F3AE4F1255C2} = {5E61AAE8-0C62-47A5-B218-A3235253710E}
{3DF3E827-7AEE-4130-9925-D6DB26C420CC} = {5E61AAE8-0C62-47A5-B218-A3235253710E}
{B9A796FE-4BEB-499A-B506-25F20C749527} = {0D1E6480-3C81-4951-8F44-BF74398BA8D4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E81DADB4-B5AD-452A-A308-813B0618F303}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Fluent API provides simple parser combinators that are assembled to express
The main goal of this API is to provide an easy-to-read grammar. Another advantage is that grammars are built at runtime, and they can be extended dynamically.

The following example is a complete parser that creates a mathematical expression tree (AST).
The source is available [here](./test/Parlot.Tests/Calc/FluentParser.cs).
The source is available [here](./src/Samples/Calc/FluentParser.cs).

```c#
public static readonly Parser<Expression> Expression;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions src/Samples/Samples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

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

</Project>
5 changes: 3 additions & 2 deletions test/Parlot.Benchmarks/Parlot.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
<PackageReference Include="Superpower" />
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Parlot.Tests\Parlot.Tests.csproj" />
<ProjectReference Include="..\..\src\Parlot\Parlot.csproj" />
<ProjectReference Include="..\..\src\Samples\Samples.csproj" />
</ItemGroup>

</Project>
239 changes: 239 additions & 0 deletions test/Parlot.Tests/BenchmarksTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
using Parlot.Benchmarks;
using Xunit;

namespace Parlot.Tests
{
public class BenchmarksTests
{
[Fact]
public void CreateCompiledSmallParser()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.CreateCompiledSmallParser();
Assert.NotNull(result);
}

[Fact]
public void CreateCompiledExpressionParser()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.CreateCompiledExpressionParser();
Assert.NotNull(result);
}

[Fact]
public void CursorMatchHello()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.CursorMatchHello();
Assert.NotNull(result);
}

[Fact]
public void CursorMatchGoodbye()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.CursorMatchGoodbye();
Assert.NotNull(result);
}

[Fact]
public void CursorMatchNone()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.CursorMatchNone();
Assert.Null(result);
}

[Fact]
public void Lookup()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.Lookup();
Assert.Equal('d', result);
}

[Fact]
public void SkipWhiteSpace_1()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.SkipWhiteSpace_1();
Assert.Equal('a', result);
}

[Fact]
public void SkipWhiteSpace_10()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.SkipWhiteSpace_10();
Assert.Equal('a', result);
}

[Fact]
public void DecodeStringWithoutEscapes()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.DecodeStringWithoutEscapes();
Assert.Equal("This is a new line \n \t and a tab and some \xa0", result);
}

[Fact]
public void DecodeStringWithEscapes()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.DecodeStringWithEscapes();
Assert.Equal("This is a new line \n \t and a tab and some \xa0", result);
}

[Fact]
public void ExpressionRawSmall()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.ExpressionRawSmall();
Assert.NotNull(result);
}

[Fact]
public void ExpressionCompiledSmall()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.ExpressionCompiledSmall();
Assert.NotNull(result);
}

[Fact]
public void ExpressionFluentSmall()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.ExpressionCompiledSmall();
Assert.NotNull(result);
}

[Fact]
public void ExpressionRawBig()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.ExpressionRawBig();
Assert.NotNull(result);
}

[Fact]
public void ExpressionCompiledBig()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.ExpressionCompiledBig();
Assert.NotNull(result);
}

[Fact]
public void ExpressionFluentBig()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.ExpressionCompiledBig();
Assert.NotNull(result);
}

[Fact]
public void BigJson()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.BigJson();
Assert.NotNull(result);
}

[Fact]
public void BigJsonCompiled()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.BigJsonCompiled();
Assert.NotNull(result);
}

[Fact]
public void DeepJson()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.DeepJson();
Assert.NotNull(result);
}

[Fact]
public void DeepJsonCompiled()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.DeepJsonCompiled();
Assert.NotNull(result);
}

[Fact]
public void LongJson()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.LongJson();
Assert.NotNull(result);
}

[Fact]
public void LongJsonCompiled()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.LongJsonCompiled();
Assert.NotNull(result);
}

[Fact]
public void WideJson()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.WideJson();
}

[Fact]
public void WideJsonCompiled()
{
var benchmarks = new ParlotBenchmarks();
benchmarks.Setup();
var result = benchmarks.WideJsonCompiled();
Assert.NotNull(result);
}

[Fact]
public void ParlotEmailCompiled()
{
var benchmarks = new RegexBenchmarks();
var result = benchmarks.ParlotEmailCompiled();
Assert.True(result);
}

[Fact]
public void ParlotEmail()
{
var benchmarks = new RegexBenchmarks();
var result = benchmarks.ParlotEmail();
Assert.True(result);
}
}
}
4 changes: 3 additions & 1 deletion test/Parlot.Tests/Parlot.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../../src/Parlot/Parlot.csproj" />
<ProjectReference Include="../../test/Parlot.Benchmarks/Parlot.Benchmarks.csproj" />
<ProjectReference Include="..\..\src\Samples\Samples.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 806c61c

Please sign in to comment.