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) }
| |