• Advertisement

Archived

This topic is now archived and is closed to further replies.

Scripting....

This topic is 5900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i add scripting support to my VC++ program. Although I just need to evaluate mathematical expressions at run-time, nothing more than that. Any help would be highly appreciated....

Share this post


Link to post
Share on other sites
Advertisement
Ouch - it can be a little hard; unless you're talking _VERY_ simple expressions, you'll have to write a lexer & parser, create a tree for the expression, then walk it to evalutate the expression.

ANTLR is a tool for creating lexers & parsers...this also has a simple calculator as one of it's examples...I extended it as a learning exercise to handle fairly complex expressions without too much difficulty, I suggest you have a play with the examples to help figuring Antlr out
www.antlr.org - Antlr's home page

Have a look on www.flipcode.com, they did a series on writing a simple script engine sometimes last year - its in their tutorial sections

The best known tools for compiler construction are 'lex' and 'yacc' ('flex' & 'bison' respectivly for non-unix systems) - they're all over the place & (I suppose) freeware - I've never used these myself...but they're always mentioned...but fairly old

Edited by - NickB on November 24, 2001 8:43:57 PM

Share this post


Link to post
Share on other sites

  • Advertisement