Re: [Dev-C++] Extracting a mathemtical expression
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jonathan W. <jon...@gm...> - 2007-04-24 08:32:07
|
Hi, >I would like to know what is the best way to extract a math expression The best way I can think of is to create a parser to read the expression. I would do it using flex and bison, and incorporating the produced parser int= o your project. Flex will chop the input into tokens (more precisely 'lex=E8mes' in french. not sure in english) based on regular expressions you specify. eg. numbers, operators... Bison is usually fed the output from Flex, and matches the tokens to syntax rules, eg. EXPRESSION: NUMBER OPERATOR NUMBER Every time bison matches a rule, you can execute some code (usually build a tree representing the input) Compilers (maybe not all, but probably) are built this way. The tree is the= n analysed, checked, and turned into something useful :D Building a simple flex file and set of bison rules for just arithmetic should be simple, and you'll probably be able to find a lot of doc' out there The flex/bison programs will parse your spec. files, creating a C or C++(some hacks required) file you can incorporate into your project. You can also use flex/bison to parse your config file if you want, while you're at it :D Best of luck, Jonathan On 4/19/07, Jan Mura <jan...@vo...> wrote: > > Hello, > > I would like to know what is the best way to extract a math expression to > IF condition. > > For instance: > I have in a configuration file an expression X=3DY and I want use the > expression in IF conditin as it is. So the condition will look like: > IF (x=3Dy( ... > > Also would like to know about some XML parser written in C. > I prefer C to C++. > Thank you. > > Jan Mura > jan...@vo... > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > --=20 <Morpheus> linux, c'est une question de VI ou de MORE |