Writing a mini-language

后端 未结 9 1827
南方客
南方客 2021-01-31 23:40

I have an application that needs to allow users to write expressions similar to excel:

(H1 + (D1 / C3)) * I8

and more complex things like

If(H1 = \'True

相关标签:
9条回答
  • 2021-02-01 00:12

    I've got a counter-example of how not to do it: Will o’ the Wisp (since this is my own code I feel confident criticizing it).

    What's good about the Code?

    1. It uses a design pattern consequently: The interpreter pattern
    2. It has a rather clean design
    3. It uses attributes in a nice way.
    4. It produces nice graphics. ;-)

    Turtle graphics http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=wisp&DownloadId=34823

    What's bad about the code?

    1. It's slow!
    2. The language is ill-defined with regards to lists (data vs. code).
    0 讨论(0)
  • 2021-02-01 00:18

    Have a look at this open source project:

    Excel Financial Functions

    0 讨论(0)
  • 2021-02-01 00:21

    Check out ANTLR. You define a language syntax, test it using a GUI tool and generate source code in a variety of languages. Open Source.

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