FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Simple expression parser for PHP.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Simple expression parser for PHP. [message #179781 is a reply to message #179776] Tue, 04 December 2012 18:20 Go to previous messageGo to previous message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma:
Member
On 12/4/12 4:49 AM, Anders Wegge Keller wrote:
> Daniel Pitts <newsgroup(dot)nospam(at)virtualinfinity(dot)net> writes:
>
>> My trouble here is not that I'm trying to look smarter, but that I'm
>> trying to minimize exposing proprietary information of my employer.
>
> You are not going to get any real help, until you present an example
> of what you need to parse. Or at least something close enough to the
> real thing, as to make sense.
>
> I understand you desire to keep proprietary information private, but
> as long as you are only able to provide vague generalities, you're not
> going to get anything but vague generalities for answers.
>
> One general answer is to look at
> http://pear.php.net/package/PHP_ParserGenerator and see if that is
> suitable for you, even though it's unmaintained.
>
I actually did find that pear package. I was hoping to avoid creating
my own grammar. The goal was to see if there was something we could use
out-of-the-box.

If I'm going to go through the trouble of creating my own grammar, I'd
probably write it in C instead of PHP, and just plug that in.

My "vague generalities" I've given are real use-cases. Perhaps I didn't
explain them enough...

Given objects (or associative arrays) Foo and Bar. I'd like to have
some call such as:

$expression = "foo['somePropertyOfFoo'] * 3";
$context = initContext(array("foo"=>$Foo, "bar"=>$Bar); // or whatever.
$result = $expressionEvaluator->evaluate($expression, $context);

This particular snippet would result in the same value as
$Foo['somePropertyOfFoo'] * 3.

where $expression is actually read from a configuration parameter somewhere.

I also need some sort of basic function calling support, even it that
requires setting up the available functions before hand.

Hopefully that makes the most sense.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to run program from php..?
Next Topic: Old version trouble with $_SERVER variables?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 14:39:54 GMT 2024

Total time taken to generate the page: 0.05015 seconds