Writing a mini-language

后端 未结 9 1832
南方客
南方客 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-01-31 23:58

    I recommend to look at CoreCalc/FunCalc work: http://www.itu.dk/people/sestoft/funcalc/

    I've used their grammar for COCO\R parser generator in production and it works really fast.

    All you need to do is: 1. get excel grammar from corecalc 2. run coco.exe on it (generates parser for excel-like expressions) 3. translate expression tree to reverse polish notation 4. simple calc

提交回复
热议问题