Writing a mini-language

后端 未结 9 2005
南方客
南方客 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).

提交回复
热议问题