[Israel.pm] embedding perl or not
Yossi Itzkovich
Yossi.Itzkovich at ecitele.com
Tue Feb 6 10:26:07 EET 2007
Hi
I have a C++ program that should read an ini file. The ini contains
simple conditions that indicate which value to be used and when, such as
:
(Example 1):
FieldName= COND:cond1 || cond2,VALUE: valueA, COND: cond3 && cond4,
VALUE: valueB
Our current code knows how to support such simple conditions. But if we
want to use complicated conditions like:
(Example 2)
COND:(cond1 || cond2) && cond3 (- and this is the simplest among
complicated)
Or to have in VALUE simple arithmetics (for example, VALUE: MAX_INT-1)
then I need much more complicated parser.
I see 2 options (except inventing the wheel):
1. Embed Perl in my code. Use current parser that I have, replace in the
original expression the cond1,cond2 tokens with the real value that I
compute in run time, and let Perl handles the boolean (+parenthesis)
expressions. Using the Exmaple2 from above, Perl will see :
(Example 2b):
COND:(1 || 0) && 1
Which Perl can calulate easily. This way the conditions can be very
complicated .
2. Another way is to use a C/C++ library that knows to do this kind of
parsing ( parenthesis, boolean)
My questions:
Which options seems the best ? Is there a C/C++ library that does what
I want ?
Thanks for your help
Yossi
More information about the Perl
mailing list