This is what I was looking for...I think. I appreciate it.

But, maybe this is your field of expertise and can help me...

How could I make this happen?

$myvars[x]=1;
$myvars[y]=6;
$expression="x+y";

Somehow run the expression and have it result with 7. What I'm trying to
figure out is how to write a function, or class to handle this. Maybe I'm
over my head or maybe someone's already done this. What I've got it my own
XML based scripting language, and I'd like to include math functions, and
IF-ELSEIF-ELSE statements (which require the same type of operation).

<setvar name="x" value="1"/>
<setvar name="y" value="6"/>
<print><eval expr="x+y"/></print>
<!-- Prints "7" -->

But the expression could be anything...technically. I've thought of using
the PHP eval() function, but since the variables are actually stored in an
array ($vars[x] and $vars[y]), I would need to first parse the expression
and replace the "x" with "$vars[x]" and likewise with the Y. But, when
parsing it, how do you know what to replace like that and what not to
replace.

I'm mumbling...but if you (or anyone out there in the great void for that
matter) understands what I'm blabbering about, please help me out!

Thanks all!


Lewis


"Andrey Hristov" <[EMAIL PROTECTED]> wrote in message
02e501c25822$e9b104e0$1601a8c0@andreywin">news:02e501c25822$e9b104e0$1601a8c0@andreywin...
> Zend/zend_language_parser.y
> Zend/zend_language_scanner.l
> you have to know something about Yacc/Bison and FLex/Lex
>
> Best regards
> Andrey Hristov
>
>
> ----- Original Message -----
> From: "OrangeHairedBoy" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, September 09, 2002 7:59 PM
> Subject: [PHP-DEV] PHP source code
>
>
> > I'm wondering if anyone knows where I can find information about how PHP
> > parser processes commands like:
> >
> > $a=$b+$c;
> > if ($b < $a) {}
> >
> > (Ones with operators)
> >
> > I've downloaded the source code, but I'm having much luck narrowing down
> my
> > search. Can anyone help me??
> >
> > Thanks!
> >
> >
> >
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to