how to parse an expression?

This is a discussion on how to parse an expression? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hallo, I have to parse an expression for example like that: 2*MY_COST1*log(4*MYCOST2)+4 How can I ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-04-2007
_mario.lat
 
Posts: n/a
Default how to parse an expression?

Hallo,
I have to parse an expression for example like that:
2*MY_COST1*log(4*MYCOST2)+4

How can I do?
any suggestions?

Thank you in advance,
Mario.
Reply With Quote
  #2 (permalink)  
Old 09-04-2007
shimmyshack
 
Posts: n/a
Default Re: how to parse an expression?

On Sep 4, 6:56 pm, "_mario.lat" <n...@libero.it> wrote:
> Hallo,
> I have to parse an expression for example like that:
> 2*MY_COST1*log(4*MYCOST2)+4
>
> How can I do?
> any suggestions?
>
> Thank you in advance,
> Mario.


not easily, you must write down the rules of maths for all the
expressions you will allow.
then you must decide whether to split or capture parts of the
expressions, constructing a series of regular expressions (rather than
just one for clarity)
which will capture the unit parts of the expression along with their
priority.

i have never attempted a maths parser, but there must be tonnes of
open source code out there, recommend you go looking for open source C
or C++ code for a project that has the functionality and look at the
code

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0