0

I am looking for a Mono/.NET expression parser generator. It must be an open-source project that I can use in MIT-licensed projects. It should be able to process a syntax description for expressions (of the complexity of arithmetic expressions) and generate a parser written in C# that outputs a custom object tree.

The expression parser should fulfill the following requirements:

  • It must not be an abandoned or an experimental project, but something stable and active.
  • The target project that will contain the generated parser must not require any additional dependencies (assemblies to reference etc.) for the parser code to work.

Some background on the second requirement

I am developing a reusable library. I would prefer that library to be "self-contained", so using my library does not result in also pulling a pile of other assemblies into the set of files to deploy.

The core features of the library should be directly usable without any additional configuration or setup code. One of the core features involves evaluating some expressions, which is what I need a parser for.

In the typical case, the core features offered by my library are used with default settings. Expressions, where present, are parsed with the built-in default parser. This should be very easy and straightforward, without any special configuration code, as implied above. It also means that at this point, I do not want to introduce a plugin-system or any such dynamic modularization that would distract from the clear and simple set of a few core features always available by default.

In some very simple cases, it is possible to use only some of the core features, but not the expression-related one. In complex cases, it is possible to use a custom expression evaluation component instead of the built-in one. In both of these cases, requiring the presence of a 3rd-party assembly that is not even used feels "wrong".

Hence my desire to avoid any additional assemblies just to make the parser code work.

  • Doesn't ANTLR have a C# version? Why is that inadequate? – Ira Baxter Dec 17 '16 at 4:11
  • @IraBaxter: As described in the readme on the C# target, the assembly that receives the generated parser C# code will also need a reference to the ANTLR runtime, which conflicts with my second requirement. I am looking for a parser generator that will generate any required parser code into one (or maybe several) source file(s). – F-H Dec 22 '16 at 21:00
  • I don't understand the 2nd requirement. It is rather hard to write a C# program (even a non-ANTLR parser) that doesn't have a library dependency. Why are your objecting to the library needed by ANTLR vs. the library needs of most programs? – Ira Baxter Dec 23 '16 at 2:09
  • @IraBaxter: I have extended the question to include a brief description of the project structure. It outlines why I would prefer to avoid having to reference any additional libraries that would have to be deployed along with my own assembly. – F-H Dec 23 '16 at 17:28
  • You are already proposing to write some code that you have to hand out. Whether it is handed out as fused together with other code whose functionality you need need, or handed out as a separate module, doesn't seem to me to be a useful distinction. Insisting on handing it out as the former just makes your code harder to engineer. The only person who will notice if you do you deployment right is you. – Ira Baxter Dec 28 '16 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.