parsing - Javascript parser for simple expression -


I would like to search for a JavaScript parser which can control and evaluate simple expressions Parser being able to evaluate regular mathematical expressions Should, and support the custom function with parameters It also has to support string handling. With string containment || Operator support is preferred, but it would be fine if + moves.

Examples of expressions that should be controlled by the Parser: <3 px <2> <3> (2 + 1) - 1

2 * funk (2, 2)

/ P>

Funk ('Hello World', 0, 5) || 'You'

Has anyone implemented such a thing or where can I find it?

I have a revised version of one (written in AS, not AP) which is custom Supports functions, but not string. Perhaps it would be easier to add string support. I will upload it somewhere else so that you can get it at .

Edit: I added basic support for string very easily, it does not support escape sequences and toJSFunction does not work, but only a few minutes to work on it Got it. Concecitation operator "||" Change on should be very easy.

Here's how you will evaluate your example expressions:

  js> var parser = new pars (); JS & gt; Parser. From ("3 * (2 + 1) - 1") Evaluate (); 8 JS & gt; Parser.parse ("2 * monk (2; 2)"). Evaluation ({function: MathPo}} 8 JS = function substr (S, start, end) {return s.sstring (start, end);} js & gt; parser.prese ("funk (Hello world) '; 0; 5) +' you '') evaluation ({function: substrate}) Hello, you do not remember why I used semicolons as a logic separator I think that there is something to differentiate between the functions and built-in "operator" functions.  

Function:

I'm playing this one small, and now (there is a version with better string support on toJSFunction functions, and you can use standard javascript escape). For the function and in the form of + as the + string, it uses a comma for different arguments as a concatenation operator, which only does addition .


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -