nodebnf
nodebnf copied to clipboard
if possible to invoke function to calcute the result?
base on the example calculator.
function doX(a,b) { return a * b }
e.g. expression is 1 x 2
i want to calculate 1 x 2 by call function doX(1,2)
thanks.
You can write a function parser which would accept a token for (doX) and map that to an internal event of functions. Then set the ( ) tokens as part of an argument tree and through a set of parse rules allow access to the compiled tokens and pass them into the event methods.