Boost logo

Boost Users :

Subject: Re: [Boost-users] a question on boost::spirit with a quick program.
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-04-07 07:00:34


On 4/7/2011 10:02 AM, Steven Watanabe wrote:
> AMDG
>
> On 04/06/2011 03:12 PM, Littlefield, Tyler wrote:
>> Sorry for all the questions; I am kind of easing into boost and finding
>> cool things i can do with it, as well as uses for a couple of projects.
>> Eventually I would like to write a small scripting language using
>> boost::spirit, just to do it and get the practice using it. As a
>> starting point, I wrote a quick calculator (that just does small single
>> operations like x+x, x*x, etc). Now i have two questions. 1) My rule
>> seems to be off. the first number comes through clearly, but no matter
>> what I put in, I always get the first number and then a 42.
>> 2) How would I go about extending this to implement order of operations,
>> parenthases, and longer operations (like 3+3*3)? I'm going to try to
>> implement a small function table so I can do tan(3), so I assume I will
>> need nultiple rules, how might that be accomplished?
>> Any comments and suggestions would be welcome. I have pasted the code
>> below. I was working from a tutorial, so early appologies if it feels
>> messy; I plan to clean up the namespace aliases and the using keywords.
>
> Spirit used to have a calculator example, but
> I can't seem to find it in the new docs.

Check out the "compiler_tutorial" directory. It's a progression from
the simplest calculator to a mini-c compiler and a virtual machine.
I intend to write a series of articles using these examples.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://boost-spirit.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net