Master branch contains proof of concept example of using Pegasus PEG generator configured as a MSBuild Task.
If you require all in code dynamic compilation, here an example at dynamic-compile branch
Requires .NET Core 2.2 SDK and Runtime.
https://dotnet.microsoft.com/download
dotnet run
If you need to have more control over parsers' compilation than you might need to use CompilePegGrammar:
Replace:
<ItemGroup>
<PegGrammar Include="Test.peg" />
</ItemGroup>
With:
<Target Name="CompilePegGrammar" BeforeTargets="BeforeBuild" >
<CompilePegGrammar InputFiles="./Test.peg" OutputFiles="./Test.peg.g.cs" ></CompilePegGrammar>
<ItemGroup>
<Compile Remove="Test.peg.g.cs" />
<Compile Include="Test.peg.g.cs" />
</ItemGroup>
</Target>
CompilePegGrammar generates files in your working directory, so don't forget to add .gitignore rule for that.
# Generated code
*.g.cs
The full example of using CompilePegGrammar can be found here: https://github.com/Konard/PegasusExample/tree/9b0d0abf0fb7cfc8ec14f01eded55a8cd62c08b8
https://www.youtube.com/playlist?list=PLeYxH0Vd8lotSflSnuA0TlaFUWQ7-E2af