Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Pegasus
Pegasus

Pegasus

John Gietzen

|
1,345 installs
| (0) | Free
Provides Language Services for Pegasus Grammars
Download

Pegasus

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

Learn more at https://github.com/otac0n/Pegasus

Example Pegasus Grammar:

@namespace MyProject
@classname ExpressionParser

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

multiplicative <double> -memoize
    = left:multiplicative "*" right:power { left * right }
    / left:multiplicative "/" right:power { left / right }
    / power

power <double>
    = left:primary "^" right:power { Math.Pow(left, right) }
    / primary

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

decimal <double>
    = value:([0-9]+ ("." [0-9]+)?) { double.Parse(value) }
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft