<commit_before>Pegasus
=======

Pegasus is a PEG-style parser generator for C# that integrates with MSBuild and Visual Studio.

Getting Started
---------------

The easiest way to get a copy of Pegasus is to install the [Pegasus NuGet package](http://nuget.org/packages/Pegasus) in Visual Studio.

    PM> Install-Package Pegasus

Once you have the package installed, all `.peg` files in your project will be compiled to their respective `.peg.cs` parser classes before every build.  These parser classes will be automatically included in compilation.

Parsers generated by Pegasus share a few common classes that are copied to the project root automatically.  The namespace of these files can be changed as desired.

Example
-------

Here is an example of a simple parser for mathematical expressions:

    @namespace MyProject
    @classname ExpressionParser
    @using Pegasus.Common

    additive <decimal>
      = left:multiplicative "+" right:additive { left + right }
      / left:multiplicative "-" right:additive { left - right }
      / multiplicative

    multiplicative <decimal>
      = left:primary "*" right:multiplicative { left * right }
      / left:primary "/" right:multiplicative { left / right }
      / primary

    primary <decimal>
      = decimal
      / "(" additive:additive ")" { additive }

    decimal <decimal>
      = value:([0-9]+ ("." [0-9]+)?) { decimal.Parse(value) }

This will take mathematical expressions as strings and evaluate them with the proper order of operations to produce a result as a decimal.<commit_msg>Added a link to the Syntax Guide wiki entry in the readme.<commit_after>Pegasus
=======

Pegasus is a PEG-style parser generator for C# that integrates with MSBuild and Visual Studio.

Getting Started
---------------

The easiest way to get a copy of Pegasus is to install the [Pegasus NuGet package](http://nuget.org/packages/Pegasus) in Visual Studio.

    PM> Install-Package Pegasus

Once you have the package installed, all `.peg` files in your project will be compiled to their respective `.peg.cs` parser classes before every build.  These parser classes will be automatically included in compilation.

Parsers generated by Pegasus share a few common classes that are copied to the project root automatically.  The namespace of these files can be changed as desired.

For help with grammar syntax, see [the syntax guide wiki entry](https://github.com/otac0n/Pegasus/wiki/Syntax-Guide)

Example
-------

Here is an example of a simple parser for mathematical expressions:

    @namespace MyProject
    @classname ExpressionParser
    @using Pegasus.Common

    additive <decimal>
      = left:multiplicative "+" right:additive { left + right }
      / left:multiplicative "-" right:additive { left - right }
      / multiplicative

    multiplicative <decimal>
      = left:primary "*" right:multiplicative { left * right }
      / left:primary "/" right:multiplicative { left / right }
      / primary

    primary <decimal>
      = decimal
      / "(" additive:additive ")" { additive }

    decimal <decimal>
      = value:([0-9]+ ("." [0-9]+)?) { decimal.Parse(value) }

This will take mathematical expressions as strings and evaluate them with the proper order of operations to produce a result as a decimal.
{'fraction_non_alphanumeric': 0.09374045801526718, 'fraction_numerical': 0.002748091603053435, 'mean_word_length': 3.3276089828269484, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4058388', 'n_tokens_mistral': 897, 'n_tokens_neox': 849, 'n_words': 367}