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
Switch to threaded view of this topic Create a new topic Submit Reply
Simple expression parser for PHP. [message #179737] Fri, 30 November 2012 23:56 Go to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
Hello,
I have a requirement that I need to take an expression and evaluate it.
I'd very much like to avoid using PHP's eval(), for obvious reasons.
I'm kind of looking for something that is similar to OGNL (a Java
library for expressions).

Speed is a plus, ease of integration is a nice-to-have. Low bug density
and active community is also a plus.
Re: Simple expression parser for PHP. [message #179741 is a reply to message #179737] Sat, 01 December 2012 17:58 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> I have a requirement that I need to take an expression and evaluate it.
>
> I'd very much like to avoid using PHP's eval(), for obvious reasons.
> I'm kind of looking for something that is similar to OGNL (a Java
> library for expressions).
>
> Speed is a plus, ease of integration is a nice-to-have. Low bug density
> and active community is also a plus.

What kind of expression are you talking about?


PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
Re: Simple expression parser for PHP. [message #179742 is a reply to message #179741] Sat, 01 December 2012 18:09 Go to previous messageGo to next message
Allodoxaphobia is currently offline  Allodoxaphobia
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
On Sat, 01 Dec 2012 18:58:03 +0100, Thomas 'PointedEars' Lahn wrote:
> Daniel Pitts wrote:
>
>> I have a requirement that I need to take an expression and evaluate it.
>>
>> I'd very much like to avoid using PHP's eval(), for obvious reasons.
>> I'm kind of looking for something that is similar to OGNL (a Java
>> library for expressions).
>>
>> Speed is a plus, ease of integration is a nice-to-have. Low bug density
>> and active community is also a plus.
>
> What kind of expression are you talking about?

"Have a nice day." :-)
Re: Simple expression parser for PHP. [message #179743 is a reply to message #179741] Sat, 01 December 2012 19:06 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/1/12 9:58 AM, Thomas 'PointedEars' Lahn wrote:
> Daniel Pitts wrote:
>
>> I have a requirement that I need to take an expression and evaluate it.
>>
>> I'd very much like to avoid using PHP's eval(), for obvious reasons.
>> I'm kind of looking for something that is similar to OGNL (a Java
>> library for expressions).
>>
>> Speed is a plus, ease of integration is a nice-to-have. Low bug density
>> and active community is also a plus.
>
> What kind of expression are you talking about?

Things along the lines of "request['some_attribute']" or "3 * someValue"
etc... Where I can specify the objects available to act upon ('request'
in the first example, 'someValue' in the second).

Some method of traversing object graphs would be useful as well. Like I
said, something similar to OGNL, but for PHP instead.
Re: Simple expression parser for PHP. [message #179744 is a reply to message #179743] Sun, 02 December 2012 11:45 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> On 12/1/12 9:58 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>> I have a requirement that I need to take an expression and evaluate it.
>>>
>>> I'd very much like to avoid using PHP's eval(), for obvious reasons.
>>> I'm kind of looking for something that is similar to OGNL (a Java
>>> library for expressions).
>>>
>>> Speed is a plus, ease of integration is a nice-to-have. Low bug density
>>> and active community is also a plus.
>>
>> What kind of expression are you talking about?
>
> Things along the lines of "request['some_attribute']" or "3 * someValue"
> etc... Where I can specify the objects available to act upon ('request'
> in the first example, 'someValue' in the second).
>
> Some method of traversing object graphs would be useful as well. Like I
> said, something similar to OGNL, but for PHP instead.

What do you need this for?


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
Re: Simple expression parser for PHP. [message #179754 is a reply to message #179744] Mon, 03 December 2012 17:28 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/2/12 3:45 AM, Thomas 'PointedEars' Lahn wrote:
> Daniel Pitts wrote:
>
>> On 12/1/12 9:58 AM, Thomas 'PointedEars' Lahn wrote:
>>> Daniel Pitts wrote:
>>>> I have a requirement that I need to take an expression and evaluate it.
>>>>
>>>> I'd very much like to avoid using PHP's eval(), for obvious reasons.
>>>> I'm kind of looking for something that is similar to OGNL (a Java
>>>> library for expressions).
>>>>
>>>> Speed is a plus, ease of integration is a nice-to-have. Low bug density
>>>> and active community is also a plus.
>>>
>>> What kind of expression are you talking about?
>>
>> Things along the lines of "request['some_attribute']" or "3 * someValue"
>> etc... Where I can specify the objects available to act upon ('request'
>> in the first example, 'someValue' in the second).
>>
>> Some method of traversing object graphs would be useful as well. Like I
>> said, something similar to OGNL, but for PHP instead.
>
> What do you need this for?
A program I'm writing. What's it to you? I've given the specific
requirements. ;-)

More specifically, it is to ease configuration of my program. The
expressions are going to be embedded into a DSL (domain-specific
language) for declaring a part of the business logic.

I'm trying to avoid using "eval" or forcing someone to write a PHP
function and reference that function by name. Most of the time, the
expressions are so simple, and only make sense in the context they
appear in the DSL.

Thanks,
Daniel.
Re: Simple expression parser for PHP. [message #179756 is a reply to message #179754] Mon, 03 December 2012 17:44 Go to previous messageGo to next message
Shake is currently offline  Shake
Messages: 40
Registered: May 2012
Karma: 0
Member
Perhaps some work with "variable variables" can help


http://php.net/manual/en/language.variables.variable.php

Rgds.
Re: Simple expression parser for PHP. [message #179757 is a reply to message #179756] Mon, 03 December 2012 18:06 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/3/12 9:44 AM, Shake wrote:
>
> Perhaps some work with "variable variables" can help
>
>
> http://php.net/manual/en/language.variables.variable.php

Not really. Also, that is an ugly ugly language feature.
Re: Simple expression parser for PHP. [message #179759 is a reply to message #179754] Mon, 03 December 2012 19:59 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> On 12/2/12 3:45 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>> On 12/1/12 9:58 AM, Thomas 'PointedEars' Lahn wrote:
>>>> Daniel Pitts wrote:
>>>> > I have a requirement that I need to take an expression and evaluate
>>>> > it.
>>>> >
>>>> > I'd very much like to avoid using PHP's eval(), for obvious
>>>> > reasons.
>>>> > I'm kind of looking for something that is similar to OGNL (a Java
>>>> > library for expressions).
>>>> >
>>>> > Speed is a plus, ease of integration is a nice-to-have. Low bug
>>>> > density and active community is also a plus.
>>>>
>>>> What kind of expression are you talking about?
>>>
>>> Things along the lines of "request['some_attribute']" or "3 * someValue"
>>> etc... Where I can specify the objects available to act upon ('request'
>>> in the first example, 'someValue' in the second).
>>>
>>> Some method of traversing object graphs would be useful as well. Like I
>>> said, something similar to OGNL, but for PHP instead.
>>
>> What do you need this for?
> A program I'm writing. What's it to you?

I am someone who could help you solve this problem.

> I've given the specific requirements. ;-)

ISTM you want a person writing or finding that software for you without any
real effort on your part. If so, you are wrong here; there are smart but
starving PHP developers out there who you should *pay* for that instead.
The smiley does not change anything.

> More specifically, it is to ease configuration of my program. The
> expressions are going to be embedded into a DSL (domain-specific
> language) for declaring a part of the business logic.

I would suggest you look more into the features of PHP instead of inventing
another OGNL-like expression language to be parsed with PHP. Without
knowing OGNL [1] well or having used it before, ISTM that many of the things
that OGNL extends Java syntax with are built into PHP these days.

For example, accessing properties instead of calling methods is facilitated
with the __get() and __set() magic methods. [2] PHP 5.4 even allows
accessing the items of array return values directly, which allows for
“$root->foo()["bar"]” or “$root->foo()[0]”. [3] (For PHP 5.3 there can be a
fallback, line “$root->foo()->items(0)”).

Further inspiration, which is probably going to use closures (introduced in
PHP 5.3, improved in PHP 5.4 [3]), can be drawn from Microsoft LINQ [4];
there is an implementation of that in PHP already [5]. Even if that is not
useful to you, writing that parser (using PHP's PCRE support [6]) should not
be too difficult a task.

> I'm trying to avoid using "eval" or forcing someone to write a PHP
> function and reference that function by name.

I can understand that and, JFYI, I had understood that already.

> Most of the time, the expressions are so simple, and only make sense in
> the context they appear in the DSL.

If you say so.


PointedEars
___________
[1] <http://commons.apache.org/ognl/>
[2] <http://php.net/manual/en/language.oop5.magic.php>
[3] <http://php.net/manual/en/migration54.new-features.php>
[4] <http://msdn.microsoft.com/en-us/library/vstudio/bb397926.aspx>
[5] <http://phplinq.codeplex.com/>
[6] <http://php.net/manual/en/book.pcre.php>
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Re: Simple expression parser for PHP. [message #179760 is a reply to message #179757] Mon, 03 December 2012 20:04 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> On 12/3/12 9:44 AM, Shake wrote:
>> Perhaps some work with "variable variables" can help
>>
>> http://php.net/manual/en/language.variables.variable.php
>
> Not really. Also, that is an ugly ugly language feature.

It is a rather nice and useful language feature if written properly. That
is, not “$$x”, but “${$x}”. And variable property access is certainly
useful in this case, considering “__get()” and “__set()”.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Re: Simple expression parser for PHP. [message #179761 is a reply to message #179759] Mon, 03 December 2012 20:30 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/3/12 11:59 AM, Thomas 'PointedEars' Lahn wrote:
> Daniel Pitts wrote:
>
>> On 12/2/12 3:45 AM, Thomas 'PointedEars' Lahn wrote:
>>> Daniel Pitts wrote:
>>>> On 12/1/12 9:58 AM, Thomas 'PointedEars' Lahn wrote:
>>>> > Daniel Pitts wrote:
>>>> >> I have a requirement that I need to take an expression and evaluate
>>>> >> it.
>>>> >>
>>>> >> I'd very much like to avoid using PHP's eval(), for obvious
>>>> >> reasons.
>>>> >> I'm kind of looking for something that is similar to OGNL (a Java
>>>> >> library for expressions).
>>>> >>
>>>> >> Speed is a plus, ease of integration is a nice-to-have. Low bug
>>>> >> density and active community is also a plus.
>>>> >
>>>> > What kind of expression are you talking about?
>>>>
>>>> Things along the lines of "request['some_attribute']" or "3 * someValue"
>>>> etc... Where I can specify the objects available to act upon ('request'
>>>> in the first example, 'someValue' in the second).
>>>>
>>>> Some method of traversing object graphs would be useful as well. Like I
>>>> said, something similar to OGNL, but for PHP instead.
>>>
>>> What do you need this for?
>> A program I'm writing. What's it to you?
>
> I am someone who could help you solve this problem.
>
>> I've given the specific requirements. ;-)
>
> ISTM you want a person writing or finding that software for you without any
> real effort on your part. If so, you are wrong here; there are smart but
> starving PHP developers out there who you should *pay* for that instead.
> The smiley does not change anything.
I am, of course, trying to do this with the least amount of effort on my
part possible. A lazy engineer is an efficient engineer ;-). This is
part of a rather large project for the rather large company I work for,
so we are already paying PHP developers. I'm not asking for anyone to
create something for free, only trying to find out what is already out
there. An hour of googling didn't really turn up much, so I thought I'd
turn to the community.

>> More specifically, it is to ease configuration of my program. The
>> expressions are going to be embedded into a DSL (domain-specific
>> language) for declaring a part of the business logic.
>
> I would suggest you look more into the features of PHP instead of inventing
> another OGNL-like expression language to be parsed with PHP. Without
> knowing OGNL [1] well or having used it before, ISTM that many of the things
> that OGNL extends Java syntax with are built into PHP these days.
Perhaps.
>
> For example, accessing properties instead of calling methods is facilitated
> with the __get() and __set() magic methods. [2] PHP 5.4 even allows
> accessing the items of array return values directly, which allows for
> “$root->foo()["bar"]” or “$root->foo()[0]”. [3] (For PHP 5.3 there can be a
> fallback, line “$root->foo()->items(0)”).
Sure it can access a single value, but can you do math in that as well?
String concatenation?
For example, I may have an expression such as: $myObject['someValue'] * 3

>
> Further inspiration, which is probably going to use closures (introduced in
> PHP 5.3, improved in PHP 5.4 [3]), can be drawn from Microsoft LINQ [4];
> there is an implementation of that in PHP already [5]. Even if that is not
> useful to you, writing that parser (using PHP's PCRE support [6]) should not
> be too difficult a task.
>
>> I'm trying to avoid using "eval" or forcing someone to write a PHP
>> function and reference that function by name.
>
> I can understand that and, JFYI, I had understood that already.
>
>> Most of the time, the expressions are so simple, and only make sense in
>> the context they appear in the DSL.
>
> If you say so.
Even if I don't say so, this is a fact of my project.


In any case, thanks for all the links, I'll look through the ones I
don't know anything about for inspiration.
>
>
> PointedEars
> ___________
> [1] <http://commons.apache.org/ognl/>
> [2] <http://php.net/manual/en/language.oop5.magic.php>
> [3] <http://php.net/manual/en/migration54.new-features.php>
> [4] <http://msdn.microsoft.com/en-us/library/vstudio/bb397926.aspx>
> [5] <http://phplinq.codeplex.com/>
> [6] <http://php.net/manual/en/book.pcre.php>
>
Re: Simple expression parser for PHP. [message #179762 is a reply to message #179754] Mon, 03 December 2012 20:39 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 03/12/12 17:28, Daniel Pitts wrote:
> On 12/2/12 3:45 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>
>>> On 12/1/12 9:58 AM, Thomas 'PointedEars' Lahn wrote:
>>>> Daniel Pitts wrote:
>>>> > I have a requirement that I need to take an expression and evaluate
>>>> > it.
>>>> >
>>>> > I'd very much like to avoid using PHP's eval(), for obvious
>>>> > reasons.
>>>> > I'm kind of looking for something that is similar to OGNL (a Java
>>>> > library for expressions).
>>>> >
>>>> > Speed is a plus, ease of integration is a nice-to-have. Low bug
>>>> > density
>>>> > and active community is also a plus.
>>>>
>>>> What kind of expression are you talking about?
>>>
>>> Things along the lines of "request['some_attribute']" or "3 * someValue"
>>> etc... Where I can specify the objects available to act upon ('request'
>>> in the first example, 'someValue' in the second).
>>>
>>> Some method of traversing object graphs would be useful as well. Like I
>>> said, something similar to OGNL, but for PHP instead.
>>
>> What do you need this for?
> A program I'm writing. What's it to you? I've given the specific
> requirements. ;-)
>
> More specifically, it is to ease configuration of my program. The
> expressions are going to be embedded into a DSL (domain-specific
> language) for declaring a part of the business logic.
>
> I'm trying to avoid using "eval" or forcing someone to write a PHP
> function and reference that function by name. Most of the time, the
> expressions are so simple, and only make sense in the context they
> appear in the DSL.
>
> Thanks,
> Daniel.
>
I still havent a clue what you are talking about.

Hint: smart people make complex things understandable by good
description. Stupid people make simple things incomprehensible, to make
them look smarter than they really are. Or at least that's what they
think...



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: Simple expression parser for PHP. [message #179763 is a reply to message #179761] Mon, 03 December 2012 22:09 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> On 12/3/12 11:59 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>> I've given the specific requirements. ;-)
>>
>> ISTM you want a person writing or finding that software for you without
>> any real effort on your part. If so, you are wrong here; there are smart
>> but starving PHP developers out there who you should *pay* for that
>> instead. The smiley does not change anything.
>
> I am, of course, trying to do this with the least amount of effort on my
> part possible. A lazy engineer is an efficient engineer ;-). This is
> part of a rather large project for the rather large company I work for,
> so we are already paying PHP developers. I'm not asking for anyone to
> create something for free, only trying to find out what is already out
> there. An hour of googling didn't really turn up much, so I thought I'd
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> turn to the community.

ACK, that is different, of course. You should say so, and tell the keywords
you have searched with, from the start next time.

>> For example, accessing properties instead of calling methods is
>> facilitated with the __get() and __set() magic methods. [2] PHP 5.4 even
>> allows accessing the items of array return values directly, which allows
>> for “$root->foo()["bar"]” or “$root->foo()[0]”. [3] (For PHP 5.3 there
>> can be a fallback, line “$root->foo()->items(0)”).
>
> Sure it can access a single value, but can you do math in that as well?

Like what?

> String concatenation?

String concatenation is a built-in. But if you must, you can do it step by
step.

> For example, I may have an expression such as: $myObject['someValue'] * 3

I fail to see the use-case.

> In any case, thanks for all the links, I'll look through the ones I
> don't know anything about for inspiration.

You're welcome.

Please trim your quotes and add an empty line before each of your blocks of
new text next time.


PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
Re: Simple expression parser for PHP. [message #179765 is a reply to message #179762] Mon, 03 December 2012 23:58 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/3/12 12:39 PM, The Natural Philosopher wrote:
> I still havent a clue what you are talking about.
>
> Hint: smart people make complex things understandable by good
> description.
Indeed, that much is true. To a point.

> Stupid people make simple things incomprehensible, to make
> them look smarter than they really are. Or at least that's what they
> think...
We'll, I don't *intentionally* make anything incomprehensible. I also
don't intentionally insult someone who asks a question I can't comprehend.

I'm working on some core framework for a large project. For one part of
this framework, I want to provide a simple, but powerful configuration
language. The configuration language is best expressed using a
Declarative syntax.

I have the rest of the configuration language worked out, but there is a
need to have some of the configured values be "calculated" real time,
based on some context.

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.
Re: Simple expression parser for PHP. [message #179766 is a reply to message #179762] Tue, 04 December 2012 01:18 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/3/12 12:39 PM, The Natural Philosopher wrote:
> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> > Daniel Pitts wrote:
>>>> >> I have a requirement that I need to take an expression and evaluate
>>>> >> it.
> I still havent a clue what you are talking about.
>
> Hint: smart people make complex things understandable by good
> description. Stupid people make simple things incomprehensible, to make
> them look smarter than they really are. Or at least that's what they
> think...
Hmm, like what you and PointedEars are doing?

I asked a simple question. Is there an expression evaluator for PHP,
other than "eval"?
Re: Simple expression parser for PHP. [message #179768 is a reply to message #179765] Tue, 04 December 2012 01:50 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/3/2012 6:58 PM, Daniel Pitts wrote:
> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>> I still havent a clue what you are talking about.
>>
>> Hint: smart people make complex things understandable by good
>> description.
> Indeed, that much is true. To a point.
>
>> Stupid people make simple things incomprehensible, to make
>> them look smarter than they really are. Or at least that's what they
>> think...
> We'll, I don't *intentionally* make anything incomprehensible. I also
> don't intentionally insult someone who asks a question I can't comprehend.
>
> I'm working on some core framework for a large project. For one part of
> this framework, I want to provide a simple, but powerful configuration
> language. The configuration language is best expressed using a
> Declarative syntax.
>
> I have the rest of the configuration language worked out, but there is a
> need to have some of the configured values be "calculated" real time,
> based on some context.
>
> 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.

Daniel, I see you've run into two of the newsgroup trolls (TNP and
"Pointed Head"). You'll be best off ignoring them - they can't help
you, and will cause you no end of grief.

I found your description quite clear, and really don't care WHY you need
it (or what keywords you used to search). I just don't know of any code
samples for what you need. Last time I needed something like that was
several years ago (and another language, but that's besides the point).
It took a while, but I got it working for that project.

But I don't know of anything like this available. You might drop a line
to the webmaster of algebra.com. He used to be a regular on here, and
he has an expression parser in his code. He might be able to help, or
maybe not. I haven't seen him around here for at least 2-3 years.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Simple expression parser for PHP. [message #179769 is a reply to message #179768] Tue, 04 December 2012 02:40 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/3/12 5:50 PM, Jerry Stuckle wrote:
> Daniel, I see you've run into two of the newsgroup trolls (TNP and
> "Pointed Head"). You'll be best off ignoring them - they can't help
> you, and will cause you no end of grief.
>
> I found your description quite clear, and really don't care WHY you need
> it (or what keywords you used to search). I just don't know of any code
> samples for what you need. Last time I needed something like that was
> several years ago (and another language, but that's besides the point).
> It took a while, but I got it working for that project.
>
> But I don't know of anything like this available. You might drop a line
> to the webmaster of algebra.com. He used to be a regular on here, and
> he has an expression parser in his code. He might be able to help, or
> maybe not. I haven't seen him around here for at least 2-3 years.

Thanks Jerry. I appreciate it.
Re: Simple expression parser for PHP. [message #179770 is a reply to message #179765] Tue, 04 December 2012 03:52 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 03/12/12 23:58, Daniel Pitts wrote:
> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>> I still havent a clue what you are talking about.
>>
>> Hint: smart people make complex things understandable by good
>> description.
> Indeed, that much is true. To a point.
>
>> Stupid people make simple things incomprehensible, to make
>> them look smarter than they really are. Or at least that's what they
>> think...
> We'll, I don't *intentionally* make anything incomprehensible. I also
> don't intentionally insult someone who asks a question I can't comprehend.
>
> I'm working on some core framework for a large project. For one part of
> this framework, I want to provide a simple, but powerful configuration
> language. The configuration language is best expressed using a
> Declarative syntax.
>
Declarative Syntax?? Like 'My knob is bigger than yours'? Thats a syntax
that declares...


Configuration language? Like 'set variable X to 3'? That's an
instruction in a language that configures x..

Stop talking buzz words and start talking English.


> I have the rest of the configuration language worked out, but there is a
> need to have some of the configured values be "calculated" real time,
> based on some context.
>

That's what programming languages do..
Are you trying to write an interpreter in php?


> 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.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: Simple expression parser for PHP. [message #179771 is a reply to message #179770] Tue, 04 December 2012 06:24 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/3/12 7:52 PM, The Natural Philosopher wrote:
> Stop talking buzz words and start talking English.

Here's some "English" for you:

*plonk*
Re: Simple expression parser for PHP. [message #179772 is a reply to message #179769] Tue, 04 December 2012 08:49 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 04.12.2012 03:40, schrieb Daniel Pitts:
> On 12/3/12 5:50 PM, Jerry Stuckle wrote:
>> Daniel, I see you've run into two of the newsgroup trolls (TNP and
>> "Pointed Head"). You'll be best off ignoring them - they can't help
>> you, and will cause you no end of grief.
>>
>> I found your description quite clear, and really don't care WHY you need
>> it (or what keywords you used to search). I just don't know of any code
>> samples for what you need. Last time I needed something like that was
>> several years ago (and another language, but that's besides the point).
>> It took a while, but I got it working for that project.
>>
>> But I don't know of anything like this available. You might drop a line
>> to the webmaster of algebra.com. He used to be a regular on here, and
>> he has an expression parser in his code. He might be able to help, or
>> maybe not. I haven't seen him around here for at least 2-3 years.
>
> Thanks Jerry. I appreciate it.
>

You should be aware that he only expressed _his_ opinion.

/Str.
Re: Simple expression parser for PHP. [message #179773 is a reply to message #179772] Tue, 04 December 2012 09:34 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 04/12/12 08:49, M. Strobel wrote:
> Am 04.12.2012 03:40, schrieb Daniel Pitts:
>> On 12/3/12 5:50 PM, Jerry Stuckle wrote:
>>> Daniel, I see you've run into two of the newsgroup trolls (TNP and
>>> "Pointed Head"). You'll be best off ignoring them - they can't help
>>> you, and will cause you no end of grief.
>>>
>>> I found your description quite clear, and really don't care WHY you need
>>> it (or what keywords you used to search). I just don't know of any code
>>> samples for what you need. Last time I needed something like that was
>>> several years ago (and another language, but that's besides the point).
>>> It took a while, but I got it working for that project.
>>>
>>> But I don't know of anything like this available. You might drop a line
>>> to the webmaster of algebra.com. He used to be a regular on here, and
>>> he has an expression parser in his code. He might be able to help, or
>>> maybe not. I haven't seen him around here for at least 2-3 years.
>>
>> Thanks Jerry. I appreciate it.
>>
>
> You should be aware that he only expressed _his_ opinion.
>
And that in fact he is King Troll here..


> /Str.
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: Simple expression parser for PHP. [message #179774 is a reply to message #179766] Tue, 04 December 2012 10:55 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >> Daniel Pitts wrote:
>>>> >>> I have a requirement that I need to take an expression and evaluate
>>>> >>> it.
>> I still havent a clue what you are talking about.
>>
>> Hint: smart people make complex things understandable by good
>> description. Stupid people make simple things incomprehensible, to make
>> them look smarter than they really are. Or at least that's what they
>> think...
> Hmm, like what you and PointedEars are doing?

Score adjusted.

> I asked a simple question. Is there an expression evaluator for PHP,
> other than "eval"?

So, here is a simple answer: No. Now go away, please.


PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
Re: Simple expression parser for PHP. [message #179775 is a reply to message #179774] Tue, 04 December 2012 10:58 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <5832026(dot)zCYLGgCScI(at)PointedEars(dot)de>,
Thomas 'PointedEars' Lahn <PointedEars(at)web(dot)de> wrote:

> Daniel Pitts wrote:
>
>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>> Daniel Pitts wrote:
>>>> >>>> I have a requirement that I need to take an expression and evaluate
>>>> >>>> it.
>>> I still havent a clue what you are talking about.
>>>
>>> Hint: smart people make complex things understandable by good
>>> description. Stupid people make simple things incomprehensible, to make
>>> them look smarter than they really are. Or at least that's what they
>>> think...
>> Hmm, like what you and PointedEars are doing?
>
> Score adjusted.
>
>> I asked a simple question. Is there an expression evaluator for PHP,
>> other than "eval"?
>
> So, here is a simple answer: No. Now go away, please.

Why you asking him to do that? That's your job.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: Simple expression parser for PHP. [message #179776 is a reply to message #179765] Tue, 04 December 2012 12:49 Go to previous messageGo to next message
Anders Wegge Keller is currently offline  Anders Wegge Keller
Messages: 30
Registered: May 2012
Karma: 0
Member
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.

--
/Wegge

Leder efter redundant peering af dk.*,linux.debian.*
Re: Simple expression parser for PHP. [message #179777 is a reply to message #179774] Tue, 04 December 2012 13:54 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
> Daniel Pitts wrote:
>
>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>> Daniel Pitts wrote:
>>>> >>>> I have a requirement that I need to take an expression and evaluate
>>>> >>>> it.
>>> I still havent a clue what you are talking about.
>>>
>>> Hint: smart people make complex things understandable by good
>>> description. Stupid people make simple things incomprehensible, to make
>>> them look smarter than they really are. Or at least that's what they
>>> think...
>> Hmm, like what you and PointedEars are doing?
>
> Score adjusted.
>
>> I asked a simple question. Is there an expression evaluator for PHP,
>> other than "eval"?
>
> So, here is a simple answer: No. Now go away, please.
>
>
> PointedEars
>

WOW! I have seen many petty things said and argued but this is the
first. Telling someone to go away? It is not like you have to read or
even try to help the person. Just ignore that which you don't like or
those who don't agree with you.
Re: Simple expression parser for PHP. [message #179778 is a reply to message #179777] Tue, 04 December 2012 14:29 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Scott Johnson wrote:

> On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>>> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>>> Daniel Pitts wrote:
>>>> >>>>> I have a requirement that I need to take an expression and
>>>> >>>>> evaluate it.
>>>> I still havent a clue what you are talking about.
>>>>
>>>> Hint: smart people make complex things understandable by good
>>>> description. Stupid people make simple things incomprehensible, to make
>>>> them look smarter than they really are. Or at least that's what they
>>>> think...
>>> Hmm, like what you and PointedEars are doing?
>>
>> Score adjusted.
>>
>>> I asked a simple question. Is there an expression evaluator for PHP,
>>> other than "eval"?
>>
>> So, here is a simple answer: No. Now go away, please.
>> [signature]
>
> WOW! I have seen many petty things said and argued but this is the
> first. Telling someone to go away? It is not like you have to read or
> even try to help the person. Just ignore that which you don't like or
> those who don't agree with you.

You want to learn to read the *whole* thread and to quote properly.


HTH

PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
Re: Simple expression parser for PHP. [message #179779 is a reply to message #179777] Tue, 04 December 2012 15:36 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/4/2012 8:54 AM, Scott Johnson wrote:
> On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>
>>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>>> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>>> Daniel Pitts wrote:
>>>> >>>>> I have a requirement that I need to take an expression and
>>>> >>>>> evaluate
>>>> >>>>> it.
>>>> I still havent a clue what you are talking about.
>>>>
>>>> Hint: smart people make complex things understandable by good
>>>> description. Stupid people make simple things incomprehensible, to make
>>>> them look smarter than they really are. Or at least that's what they
>>>> think...
>>> Hmm, like what you and PointedEars are doing?
>>
>> Score adjusted.
>>
>>> I asked a simple question. Is there an expression evaluator for PHP,
>>> other than "eval"?
>>
>> So, here is a simple answer: No. Now go away, please.
>>
>>
>> PointedEars
>>
>
> WOW! I have seen many petty things said and argued but this is the
> first. Telling someone to go away? It is not like you have to read or
> even try to help the person. Just ignore that which you don't like or
> those who don't agree with you.

What do you expect from a troll?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Simple expression parser for PHP. [message #179780 is a reply to message #179772] Tue, 04 December 2012 18:09 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/4/12 12:49 AM, M. Strobel wrote:
> Am 04.12.2012 03:40, schrieb Daniel Pitts:
>> On 12/3/12 5:50 PM, Jerry Stuckle wrote:
>>> Daniel, I see you've run into two of the newsgroup trolls (TNP and
>>> "Pointed Head"). You'll be best off ignoring them - they can't help
>>> you, and will cause you no end of grief.
>>>
>>> I found your description quite clear, and really don't care WHY you need
>>> it (or what keywords you used to search). I just don't know of any code
>>> samples for what you need. Last time I needed something like that was
>>> several years ago (and another language, but that's besides the point).
>>> It took a while, but I got it working for that project.
>>>
>>> But I don't know of anything like this available. You might drop a line
>>> to the webmaster of algebra.com. He used to be a regular on here, and
>>> he has an expression parser in his code. He might be able to help, or
>>> maybe not. I haven't seen him around here for at least 2-3 years.
>>
>> Thanks Jerry. I appreciate it.
>>
>
> You should be aware that he only expressed _his_ opinion.

I am aware of that. He is also the first who answered directly my
question. PointedEars seems like he's genuinely interested in helping
me, but doesn't seem to believe me that I understand my requirements.

TNP on the other hand, seems like he wants to just insult me because
*he* doesn't understand my description of my requirements. I use too
many big words apparently.
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 next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
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.
Re: Simple expression parser for PHP. [message #179782 is a reply to message #179778] Tue, 04 December 2012 18:25 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 12/4/12 6:29 AM, Thomas 'PointedEars' Lahn wrote:
> Scott Johnson wrote:
>
>> On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
>>> Daniel Pitts wrote:
>>>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>>> > On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>>>> Daniel Pitts wrote:
>>>> >>>>>> I have a requirement that I need to take an expression and
>>>> >>>>>> evaluate it.
>>>> > I still havent a clue what you are talking about.
>>>> >
>>>> > Hint: smart people make complex things understandable by good
>>>> > description. Stupid people make simple things incomprehensible, to make
>>>> > them look smarter than they really are. Or at least that's what they
>>>> > think...
>>>> Hmm, like what you and PointedEars are doing?
>>>
>>> Score adjusted.
>>>
>>>> I asked a simple question. Is there an expression evaluator for PHP,
>>>> other than "eval"?
>>>
>>> So, here is a simple answer: No. Now go away, please.
>>> [signature]
>>
>> WOW! I have seen many petty things said and argued but this is the
>> first. Telling someone to go away? It is not like you have to read or
>> even try to help the person. Just ignore that which you don't like or
>> those who don't agree with you.
>
> You want to learn to read the *whole* thread and to quote properly.

First, PointedEars, I want to apologize for venting my frustration with
TNP on you. I feel like you were genuinely *trying* to help.

The simple answer is, as you said, no. There isn't any well known
supported expression evaluator in PHP. Thank you for your time.
Re: Simple expression parser for PHP. [message #179784 is a reply to message #179781] Tue, 04 December 2012 18:52 Go to previous messageGo to next message
Anders Wegge Keller is currently offline  Anders Wegge Keller
Messages: 30
Registered: May 2012
Karma: 0
Member
Daniel Pitts <newsgroup(dot)nospam(at)virtualinfinity(dot)net> writes:

> 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...

I miss at least one thing: How complex expressions do you need to
handle? If you can impose a limitation to very simple expressions, you
might be able to handle them with a set of regular expressions instead
of a tokenizer. But the complexity of that will grow exponentially, so
you'd pretty soon want to do something else.

> 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.

Apart from the complexity of the expressions, I'd say build your own
lexer and parser. *OR* if you have your own choice of DSL, see if you
can use Lua. <http://php.net/manual/en/book.lua.php>

By using lua, you can isolate your DSL from the rest of the
application, which I guess is one concern, since you started by asking
for a way to avoid eval().

--
/Wegge

Leder efter redundant peering af dk.*,linux.debian.*
Re: Simple expression parser for PHP. [message #179785 is a reply to message #179782] Tue, 04 December 2012 22:23 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Daniel Pitts wrote:

> On 12/4/12 6:29 AM, Thomas 'PointedEars' Lahn wrote:
>> Scott Johnson wrote:
>>> On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
>>>> Daniel Pitts wrote:
>>>> > On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>>> >> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>>>>> Daniel Pitts wrote:
>>>> >>>>>>> I have a requirement that I need to take an expression and
>>>> >>>>>>> evaluate it.
>>>> >> I still havent a clue what you are talking about.
>>>> >>
>>>> >> Hint: smart people make complex things understandable by good
>>>> >> description. Stupid people make simple things incomprehensible, to
>>>> >> make them look smarter than they really are. Or at least that's what
>>>> >> they think...
>>>> > Hmm, like what you and PointedEars are doing?
>>>>
>>>> Score adjusted.
>>>>
>>>> > I asked a simple question. Is there an expression evaluator for PHP,
>>>> > other than "eval"?
>>>>
>>>> So, here is a simple answer: No. Now go away, please.
>>>> [signature]
>>>
>>> WOW! I have seen many petty things said and argued but this is the
>>> first. Telling someone to go away? It is not like you have to read or
>>> even try to help the person. Just ignore that which you don't like or
>>> those who don't agree with you.
>>
>> You want to learn to read the *whole* thread and to quote properly.
>
> First, PointedEars, I want to apologize for venting my frustration with
> TNP on you. I feel like you were genuinely *trying* to help.
>
> The simple answer is, as you said, no. There isn't any well known
> supported expression evaluator in PHP. Thank you for your time.

ACK(nowledged).


Regards,

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Re: Simple expression parser for PHP. [message #179791 is a reply to message #179778] Wed, 05 December 2012 07:58 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 12/4/2012 6:29 AM, Thomas 'PointedEars' Lahn wrote:
> Scott Johnson wrote:
>
>> On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
>>> Daniel Pitts wrote:
>>>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>>> > On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>>>> Daniel Pitts wrote:
>>>> >>>>>> I have a requirement that I need to take an expression and
>>>> >>>>>> evaluate it.
>>>> > I still havent a clue what you are talking about.
>>>> >
>>>> > Hint: smart people make complex things understandable by good
>>>> > description. Stupid people make simple things incomprehensible, to make
>>>> > them look smarter than they really are. Or at least that's what they
>>>> > think...
>>>> Hmm, like what you and PointedEars are doing?
>>>
>>> Score adjusted.
>>>
>>>> I asked a simple question. Is there an expression evaluator for PHP,
>>>> other than "eval"?
>>>
>>> So, here is a simple answer: No. Now go away, please.
>>> [signature]
>>
>> WOW! I have seen many petty things said and argued but this is the
>> first. Telling someone to go away? It is not like you have to read or
>> even try to help the person. Just ignore that which you don't like or
>> those who don't agree with you.
>
> You want to learn to read the *whole* thread and to quote properly.
>
>
> HTH
>
> PointedEars
>

No.
Re: Simple expression parser for PHP. [message #179792 is a reply to message #179777] Wed, 05 December 2012 09:24 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 04/12/12 13:54, Scott Johnson wrote:
> On 12/4/2012 2:55 AM, Thomas 'PointedEars' Lahn wrote:
>> Daniel Pitts wrote:
>>
>>> On 12/3/12 12:39 PM, The Natural Philosopher wrote:
>>>> On 03/12/12 17:28, Daniel Pitts wrote:
>>>> >>>> Daniel Pitts wrote:
>>>> >>>>> I have a requirement that I need to take an expression and
>>>> >>>>> evaluate
>>>> >>>>> it.
>>>> I still havent a clue what you are talking about.
>>>>
>>>> Hint: smart people make complex things understandable by good
>>>> description. Stupid people make simple things incomprehensible, to make
>>>> them look smarter than they really are. Or at least that's what they
>>>> think...
>>> Hmm, like what you and PointedEars are doing?
>>
>> Score adjusted.
>>
>>> I asked a simple question. Is there an expression evaluator for PHP,
>>> other than "eval"?
>>
>> So, here is a simple answer: No. Now go away, please.
>>
>>
>> PointedEars
>>
>
> WOW! I have seen many petty things said and argued but this is the
> first. Telling someone to go away? It is not like you have to read or
> even try to help the person. Just ignore that which you don't like or
> those who don't agree with you.
No: ignore that which is essentially incomrehensible.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: Simple expression parser for PHP. [message #179805 is a reply to message #179792] Fri, 07 December 2012 00:53 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 12/5/2012 1:24 AM, The Natural Philosopher wrote:

>>>
>>> So, here is a simple answer: No. Now go away, please.
>>>
>>>
>>> PointedEars
>>>
>>
>> WOW! I have seen many petty things said and argued but this is the
>> first. Telling someone to go away? It is not like you have to read or
>> even try to help the person. Just ignore that which you don't like or
>> those who don't agree with you.
> No: ignore that which is essentially incomrehensible.
>
>
>

OK OK I concede. I was taken by surprise by the comment and it was a
knee jerk comment.

Scotty
Re: Simple expression parser for PHP. [message #179824 is a reply to message #179737] Mon, 10 December 2012 17:40 Go to previous message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 11/30/12 3:56 PM, Daniel Pitts wrote:
> Hello,
> I have a requirement that I need to take an expression and evaluate it.
> I'd very much like to avoid using PHP's eval(), for obvious reasons.
> I'm kind of looking for something that is similar to OGNL (a Java
> library for expressions).
>
> Speed is a plus, ease of integration is a nice-to-have. Low bug density
> and active community is also a plus.

To everyone who helped (or tried to help). I eventually went with using
create_function()

The expressions themselves are trusted, and this gives the most
flexibility. The syntax of PHP isn't the best for this context, but is
good enough.
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Fri Oct 18 08:32:46 GMT 2024

Total time taken to generate the page: 0.02090 seconds