Hi Bill, Thanks a lot for your help ! I have downloaded and installed Parser::Yapp module. But I am not getting headstart in understanding it's use ! I tried searching internet for the docu but could not get docu. Maybe examples and some documentation will help me !
Can you please guide me in this regard ? With Best Regards, Vidyadhar -----Original Message----- From: $Bill Luebkert [mailto:[EMAIL PROTECTED] Sent: 21 January 2005 14:23 To: Jangale V-S SPEL-TIT Cc: '[email protected]' Subject: Re: Evaluate expression You could create a hash for the vrbls and associate the name with a hash element (undefined until you determine the value of the vrbl). my %vrbls; $vrbls{A} = undef; $vrbls{B} = undef; $vrbls{C} = undef; $vrbls{D} = undef; $vrbls{RESULT} = undef; $vrbls{DATAFROMFILE} = undef; $vrbls{DATACAL} = undef; Now all you need to do is evaluate the expressions. Of course you'll need to split each line and decide if you have a vrbl or an operation to perform. Another hash would help with all the operators in it and a coderef to the apporpriate subroutine. There may be a Perl lex/yacc type module to help you write an LALR grammar in Perl (or possibly write your own converter from C YACC code to Perl). Try searching CPAN for a LALR parser in Perl. Parse::Yapp, Parse::YALALR or Parse::RPN may be useful. >>2) Evalute the variables on right hand side .. That's where the grammar would come in - you could verify the grammar and actually execute it as you parse the file. >>3) After values of all variables on right hand side are known, evaluate >>complete expression with a function (this function will actually calculate >>the >> the resultant value of Varible on right hand side eg. >> >> $A = Eval { $LEFT{A} } # Just for example You don't need that step - step 2 would have done that already. You'll have to decide if you want to use some sort of RPN or stack based grammar or maybe just a left to right line parse with the ability to apply operator precedence. Parse::Yapp looks like a good place to start. -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Admin mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
