What is the closest to pyparsing that exists for .NET?

What interests me especially is the ability to define the grammar in the code as regular code without unnecessary jerking.

I know that I can use IronPython. I do not want.

UPDATE:

To further explain what I'm looking for, I include some sample piping code. This is an incomplete parser for converting emacs bright keys to more conventions. This example, of course, is small enough for the string functions to be sufficient, but this is just to show the purity and brevity of the pyrapes.

from pyparsing import Literal, OneOrMore, Optional, Word, printables, replaceWith CTRL_MODIFIER = Literal('C').setParseAction(replaceWith('Ctrl')) META_MODIFIER = Literal('M').setParseAction(replaceWith('Alt')) MODIFIER = CTRL_MODIFIER | META_MODIFIER # Note operator overloading SEPARATOR = Literal('-').setParseAction(replaceWith('+')) MODIFIER_LIST = OneOrMore(MODIFIER + SEPARATOR) KEY = Word(printables) # This is a "word" composed of any number of printable characters. # The lambda functions here just join the tokens with the literal string # on which .join is called. STROKE = (Optional(MODIFIER_LIST) + KEY).setParseAction( lambda tokens: ' '.join([str(token) for token in tokens])) BINDING = OneOrMore(STROKE).setParseAction( lambda tokens: ', '.join([str(token) for token in tokens])) # Example usage: # >>> BINDING.transformString('M-/') # Alt + / # >>> BINDING.transformString('Cx C-f') # Ctrl + x, Ctrl + f # >>> BINDING.transformString('Cx f') # Ctrl + x, f # >>> BINDING.transformString('Cx Mc M-butterfly') # Ctrl + x, Alt + c, Alt + butterfly 

I would like to be able to write grammar in .NET with the same ease in the form of several lines.

+4
source share
3 answers

Take a look at: Irony It allows you to define your grammar in C # code

+2
source

You can try NParsec , but it doesn't seem to be actively developing.

+2
source

The OSLO project, which will not be released for several more years, will be a redesigned version of pyparsing.

+1
source

All Articles