Constructing a simple interpreter

后端 未结 9 2156
别跟我提以往
别跟我提以往 2020-12-15 11:41

I’m starting a project where I need to implement a light-weight interpreter. The interpreter is used to execute simple scientific algorithms. The programming language that t

相关标签:
9条回答
  • 2020-12-15 11:47

    Have you considered using IronPython? It's easy to use from .NET and it seems to meet all your requirements. I understand that python is fairly popular for scientific programming, so it's possible your users will already be familiar with it.

    0 讨论(0)
  • 2020-12-15 11:49

    I am surprised no one has mentioned xtext yet. It is available as Eclipse plugin and IntelliJ plugin. It provides not just the parser like ANTLR but the whole pipeline (including parser, linker, typechecker, compiler) needed for a DSL. You can check it's source code on Github for understanding how, an interpreter/compiler works.

    0 讨论(0)
  • 2020-12-15 11:56

    I'd recommend leveraging the DLR to do this, as this is exactly what it is designed for.

    Create Your Own Language ontop of the DLR

    0 讨论(0)
  • 2020-12-15 12:00

    The programming language that this interpreter will use should be simple, since it is targeting non- software developers.

    I'm going to chime in on this part of your question. A simple language is not what you really want to hand to non-software developers. Stripped down languages require more effort by the programmer. What you really want id a well designed and well implemented Domain Specific Language (DSL).

    In this sense I will second what Norman Ramsey recommends with Lua. It has an excellent reputation as a base for high quality DSLs. A well documented and useful DSL takes time and effort, but will save everyone time in the long run when domain experts can be brought up to speed quickly and require minimal support.

    0 讨论(0)
  • 2020-12-15 12:02

    It might sound odd, but Game Scripting Mastery is a great resource for learning about parsing, compiling and interpreting code.

    You should really check it out:

    http://www.amazon.com/Scripting-Mastery-Premier-Press-Development/dp/1931841578

    0 讨论(0)
  • 2020-12-15 12:05

    Lua was designed as an extensible interpreter for use by non-programmers. (The first users were Brazilian petroleum geologists although the user base has broadened considerably since then.) You can take Lua and easily add your scientific algorithms, visualizations, what have you. It's superbly well engineered and you can get on with the task at hand.

    Of course, if what you really want is the fun of building your own, then the other advice is reasonable.

    0 讨论(0)
提交回复
热议问题