You are here: Re: I need a mini "logic interpreter" « PHP Programming Language « IT news, forums, messages
Re: I need a mini "logic interpreter"

Posted by the DtTvB on 05/28/06 14:58

I made one

Source file: http://dttvb.yi.org/tparser.phps
There are still some problems about nesting. But it works quite well.

-- TESTS --
echo dtsparse('[[if 2==2]]this condition is true[[else]]this condition
is false[[endif]]');
// Outputs this condition is true
echo dtsparse('[[if 3==2]]this condition is true[[else]]this condition
is false[[endif]]');
// Outputs this condition is false
echo dtsparse('[[if 3>2]]this condition is true[[else]]this condition
is false[[endif]]');
// Outputs this condition is true
echo dtsparse('before if[[if 3==3]], this condition is true[[endif]],
after if');
// Outputs before if, this condition is true, after if
echo dtsparse('before if[[if 3==2]], this condition is true[[endif]],
after if');
// Outputs before if, after if
echo dtsparse('[[for 5,10]]aa [[endfor]]');
// Outputs aa aa aa aa aa aa
echo dtsparse('[[for 5 to 10]][[index]],[[endfor]]finish');
// Outputs 5,6,7,8,9,10,finish

Is that what you want? Sorry if it's not.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация