ilikeopensource Posted December 21, 2006 Share Posted December 21, 2006 Hello,i need help in finding a solution for my web app problem. i am developing a internal web application for my company .. i would like my users to input mathematical formulas and some instructions...the server should then interpret these formulas and display the results in a specified format. i do not want my users to learn PHP, PERL or some other programing language ...i came across JavaCC .. is there a way to use JavaCC with PHP5 ? ... or is there an equivalent of JavaCC in php ? ....or is there a common parser/interpreter which will allow the user to input simple commands and get a PHP script out of it..so that my server can run it and produce results ?? ...for example say the user input is SUM(A1 - A3) meaning add A1+A2+A3 the corresponding Php code should befunction SUM($A){for($i=0;$i<count($A);i++){$RESULT += $A[$i];}return $RESULT;}well thats just a simple example ... i dont want to reinvent the wheel .. i would be happy if some could point me to useful resources ....thanks Link to comment https://forums.phpfreaks.com/topic/31510-writing-own-simple-langauge-using-php/ Share on other sites More sharing options...
makeshift_theory Posted December 21, 2006 Share Posted December 21, 2006 You could try placing the "Sum(A1:A3)" in a text area then have php grab the text area and then search for the pattern. Link to comment https://forums.phpfreaks.com/topic/31510-writing-own-simple-langauge-using-php/#findComment-145952 Share on other sites More sharing options...
ilikeopensource Posted December 22, 2006 Author Share Posted December 22, 2006 Thank you for your reply... i did more search on what i need ... may be i need is just a parser ? ... is there a customizable parser written in PHP ? for which i can define rules ..and get output as PHP ?? thanks in advance Link to comment https://forums.phpfreaks.com/topic/31510-writing-own-simple-langauge-using-php/#findComment-146461 Share on other sites More sharing options...
maexus Posted December 22, 2006 Share Posted December 22, 2006 Actually I'm in need of something very similar. Link to comment https://forums.phpfreaks.com/topic/31510-writing-own-simple-langauge-using-php/#findComment-146492 Share on other sites More sharing options...
utexas_pjm Posted December 22, 2006 Share Posted December 22, 2006 There are out of the box XML parsers. You'll still spend some cycles converting your pseudo syntax to valid XML, but the transformation from XML to php should be rather painless. From someone who's taken compiler classes in college you want to stay away from parsing your own language from scratch, that is unless you have a fondness for state machines and headaches. Link to comment https://forums.phpfreaks.com/topic/31510-writing-own-simple-langauge-using-php/#findComment-146496 Share on other sites More sharing options...
eric1235711 Posted December 22, 2006 Share Posted December 22, 2006 I like the idea of making some kind of parser!!!but, you should be specific about wich kind of formulas they intend to do...for example, I worked with a school gestion software. the teachers put their formulas like ($t1 + $t2*3)/2 and php just had to run eval... no need for parsers...what's the complexity of your formulas?for example, It´s not that hard to do an simple lisp parser... Link to comment https://forums.phpfreaks.com/topic/31510-writing-own-simple-langauge-using-php/#findComment-146559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.