I am creating online calculator which allows user to perform mathmatical operations. In core, I am using math.js evaluator to get the results of the operations.
Currently, user can type operations one by one in command line, but next step of my idea should allow user to write few lines of javascript (or custom syntax) code in some textarea or different editor and then evaluate whole input. Problem is that math.js eval cannot handle that, but, it allows to extend the built-in functionality by custom functions.
Is there any way to extend the library to handle for/if/switch statements? Or maybe should I think about some different approach (parse each line and check for specific statement name? What should I do with brackets them?).
Has anyone enforced similar problem? Any suggestions how I can handle that problem?